Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with Nextcloud 18 and MySQL 8.0 #362

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mh0rst
Copy link

@mh0rst mh0rst commented Apr 25, 2020

Increase Nextcloud compatibility version and fix use of reserved word "grouping" with MySQL 8 (https://dev.mysql.com/doc/refman/8.0/en/keywords.html)

@@ -10,6 +10,6 @@
<dependencies>
<lib>curl</lib>
<owncloud min-version="7.0.3" max-version="10.0.10" />
<nextcloud min-version="9.1" max-version="17" />
<nextcloud min-version="9.1" max-version="18" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks right.

@@ -136,7 +136,7 @@ public function getListing($FOLDER, $showdel) {
// Get the listing from the database
$requery = false;
$uid = \OCP\User::getUser();
$query = "SELECT id, name, grouping, mtime, deleted FROM *PREFIX*ownnote WHERE uid=? ORDER BY name";
$query = "SELECT id, name, `grouping`, mtime, deleted FROM *PREFIX*ownnote WHERE uid=? ORDER BY name";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious about this change. I don't see this needed based on column type and MySQL 8 release/change notes so am curious about documentation as to why these backticks are required now.

Copy link
Author

@mh0rst mh0rst Apr 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take a look at the link I provided in the PR description (https://dev.mysql.com/doc/refman/8.0/en/keywords.html):

GROUPING (R); added in 8.0.1 (reserved)

Grouping is a reserved keyword starting with MySQL 8.0.1, hence its unquoted usage in queries will cause an error.
Example output from a MySQL database with ownnote installed:

mysql> SELECT id, name, grouping, mtime, deleted FROM oc_ownnote ORDER BY name LIMIT 1;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ', mtime, deleted FROM oc_ownnote ORDER BY name LIMIT 1' at line 1
mysql> SELECT id, name, `grouping`, mtime, deleted FROM oc_ownnote ORDER BY name LIMIT 1;
+----+------------+----------+------------+---------+
| id | name       | grouping | mtime      | deleted |
+----+------------+----------+------------+---------+
| 34 | Abrechnung |          | 1587824928 |       0 |
+----+------------+----------+------------+---------+
1 row in set (0.00 sec)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mh0rst I apologize. I did not see that GROUPING had become reserved. Thank you for educating me.

@apotek
Copy link
Contributor

apotek commented Apr 26, 2020

@Fmstrat I am currently testing this PR, and it is working. I am not running MySQL 8 on my test instance, so I cannot verify that it is working there, but it certainly is not causing any backwards compatibility issues for me and app is working fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants