-
Notifications
You must be signed in to change notification settings - Fork 42
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 is a reserved keyword starting with MySQL 8.0.1, hence its unquoted usage in queries will cause an error.
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
$results = $this->db->executeQuery($query, Array($uid))->fetchAll(); | ||
$results2 = $results; | ||
if ($results) | ||
|
@@ -164,7 +164,7 @@ public function getListing($FOLDER, $showdel) { | |
} | ||
} | ||
if ($requery) { | ||
$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"; | ||
$results = $this->db->executeQuery($query, Array($uid))->fetchAll(); | ||
$requery = false; | ||
} | ||
|
@@ -248,7 +248,7 @@ public function getListing($FOLDER, $showdel) { | |
} | ||
} | ||
if ($requery) { | ||
$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"; | ||
$results = $this->db->executeQuery($query, Array($uid))->fetchAll(); | ||
} | ||
// Now also make sure the files exist, they may not if the user switched folders in admin. | ||
|
@@ -304,7 +304,7 @@ public function createNote($FOLDER, $in_name, $in_group) { | |
$fileindb = false; | ||
$filedeldb = false; | ||
$ret = -1; | ||
$query = "SELECT id, name, grouping, mtime, deleted FROM *PREFIX*ownnote WHERE uid=? and name=? and grouping=?"; | ||
$query = "SELECT id, name, `grouping`, mtime, deleted FROM *PREFIX*ownnote WHERE uid=? and name=? and `grouping`=?"; | ||
$results = $this->db->executeQuery($query, Array($uid, $name, $group))->fetchAll(); | ||
foreach($results as $result) | ||
if ($result['deleted'] == 0) { | ||
|
@@ -314,7 +314,7 @@ public function createNote($FOLDER, $in_name, $in_group) { | |
$filedeldb = true; | ||
} | ||
if ($filedeldb) { | ||
$query = "DELETE FROM *PREFIX*ownnote WHERE uid=? and name=? and grouping=?"; | ||
$query = "DELETE FROM *PREFIX*ownnote WHERE uid=? and name=? and `grouping`=?"; | ||
$results = $this->db->executeQuery($query, Array($uid, $name, $group)); | ||
} | ||
if (! $fileindb) { | ||
|
@@ -329,7 +329,7 @@ public function createNote($FOLDER, $in_name, $in_group) { | |
$mtime = $info['mtime']; | ||
} | ||
} | ||
$query = "INSERT INTO *PREFIX*ownnote (uid, name, grouping, mtime, note, shared) VALUES (?,?,?,?,?,?)"; | ||
$query = "INSERT INTO *PREFIX*ownnote (uid, name, `grouping`, mtime, note, shared) VALUES (?,?,?,?,?,?)"; | ||
$this->db->executeQuery($query, Array($uid,$name,$group,$mtime,'','')); | ||
$ret = $this->db->lastInsertId('*PREFIX*ownnote'); | ||
} | ||
|
@@ -341,9 +341,9 @@ public function deleteNote($FOLDER, $name, $group) { | |
$now = new DateTime(); | ||
$mtime = $now->getTimestamp(); | ||
$uid = \OCP\User::getUser(); | ||
$query = "UPDATE *PREFIX*ownnote set note='', deleted=1, mtime=? WHERE uid=? and name=? and grouping=?"; | ||
$query = "UPDATE *PREFIX*ownnote set note='', deleted=1, mtime=? WHERE uid=? and name=? and `grouping`=?"; | ||
$results = $this->db->executeQuery($query, Array($mtime, $uid, $name, $group)); | ||
$query = "SELECT id FROM *PREFIX*ownnote WHERE uid=? and name=? and grouping=?"; | ||
$query = "SELECT id FROM *PREFIX*ownnote WHERE uid=? and name=? and `grouping`=?"; | ||
$results = $this->db->executeQuery($query, Array($uid, $name, $group))->fetchAll(); | ||
foreach($results as $result) { | ||
$query2 = "DELETE FROM *PREFIX*ownnote_parts WHERE id=?"; | ||
|
@@ -363,7 +363,7 @@ public function deleteNote($FOLDER, $name, $group) { | |
public function editNote($name, $group) { | ||
$ret = ""; | ||
$uid = \OCP\User::getUser(); | ||
$query = "SELECT id,note FROM *PREFIX*ownnote WHERE uid=? and name=? and grouping=?"; | ||
$query = "SELECT id,note FROM *PREFIX*ownnote WHERE uid=? and name=? and `grouping`=?"; | ||
$results = $this->db->executeQuery($query, Array($uid, $name, $group))->fetchAll(); | ||
foreach($results as $result) { | ||
$ret = $result['note']; | ||
|
@@ -397,7 +397,7 @@ public function saveNote($FOLDER, $name, $group, $content, $in_mtime) { | |
$mtime = $info['mtime']; | ||
} | ||
} | ||
$query = "UPDATE *PREFIX*ownnote set note='', mtime=? WHERE uid=? and name=? and grouping=?"; | ||
$query = "UPDATE *PREFIX*ownnote set note='', mtime=? WHERE uid=? and name=? and `grouping`=?"; | ||
$results = $this->db->executeQuery($query, Array($mtime, $uid, $name, $group)); | ||
$query = "DELETE FROM *PREFIX*ownnote_parts WHERE id=?"; | ||
$results = $this->db->executeQuery($query, Array($id)); | ||
|
@@ -426,7 +426,7 @@ public function renameNote($FOLDER, $name, $group, $in_newname, $in_newgroup) { | |
public function deleteGroup($FOLDER, $group) { | ||
// We actually need to just rename all the notes | ||
$uid = \OCP\User::getUser(); | ||
$query = "SELECT id, name, grouping, mtime FROM *PREFIX*ownnote WHERE deleted=0 and uid=? and grouping=?"; | ||
$query = "SELECT id, name, `grouping`, mtime FROM *PREFIX*ownnote WHERE deleted=0 and uid=? and `grouping`=?"; | ||
$results = $this->db->executeQuery($query, Array($uid, $group))->fetchAll(); | ||
foreach($results as $result) { | ||
$this->renameNote($FOLDER, $result['name'], $group, $result['name'], ''); | ||
|
@@ -436,7 +436,7 @@ public function deleteGroup($FOLDER, $group) { | |
|
||
public function renameGroup($FOLDER, $group, $newgroup) { | ||
$uid = \OCP\User::getUser(); | ||
$query = "SELECT id, name, grouping, mtime FROM *PREFIX*ownnote WHERE deleted=0 and uid=? and grouping=?"; | ||
$query = "SELECT id, name, `grouping`, mtime FROM *PREFIX*ownnote WHERE deleted=0 and uid=? and `grouping`=?"; | ||
$results = $this->db->executeQuery($query, Array($uid, $group))->fetchAll(); | ||
foreach($results as $result) { | ||
$this->renameNote($FOLDER, $result['name'], $group, $result['name'], $newgroup); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks right.