[PATCH] Quote MySql 8.0 reserved keywords
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- aurweb/git/update.py | 4 ++-- schema/aur-schema.sql | 4 ++-- upgrading/3.0.0.txt | 4 ++-- upgrading/3.1.0.txt | 2 +- web/lib/aurjson.class.php | 6 +++--- web/lib/pkgfuncs.inc.php | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/aurweb/git/update.py b/aurweb/git/update.py index 0614e9e..39128f8 100755 --- a/aurweb/git/update.py +++ b/aurweb/git/update.py @@ -180,13 +180,13 @@ def save_metadata(metadata, conn, user): # Add package groups. if 'groups' in pkginfo: for group in pkginfo['groups']: - cur = conn.execute("SELECT ID FROM Groups WHERE Name = ?", + cur = conn.execute("SELECT ID FROM `Groups` WHERE Name = ?", [group]) row = cur.fetchone() if row: groupid = row[0] else: - cur = conn.execute("INSERT INTO Groups (Name) VALUES (?)", + cur = conn.execute("INSERT INTO `Groups` (Name) VALUES (?)", [group]) conn.commit() groupid = cur.lastrowid diff --git a/schema/aur-schema.sql b/schema/aur-schema.sql index 79de3f2..f05f40a 100644 --- a/schema/aur-schema.sql +++ b/schema/aur-schema.sql @@ -149,7 +149,7 @@ CREATE TABLE PackageLicenses ( -- Information about groups -- -CREATE TABLE Groups ( +CREATE TABLE `Groups` ( ID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, Name VARCHAR(255) NOT NULL, PRIMARY KEY (ID), @@ -164,7 +164,7 @@ CREATE TABLE PackageGroups ( GroupID INTEGER UNSIGNED NOT NULL, PRIMARY KEY (PackageID, GroupID), FOREIGN KEY (PackageID) REFERENCES Packages(ID) ON DELETE CASCADE, - FOREIGN KEY (GroupID) REFERENCES Groups(ID) ON DELETE CASCADE + FOREIGN KEY (GroupID) REFERENCES `Groups`(ID) ON DELETE CASCADE ) ENGINE = InnoDB; diff --git a/upgrading/3.0.0.txt b/upgrading/3.0.0.txt index b134b79..4f9c70f 100644 --- a/upgrading/3.0.0.txt +++ b/upgrading/3.0.0.txt @@ -200,7 +200,7 @@ CREATE TABLE PackageRelations ( 17. Create tables to store package groups: ---- -CREATE TABLE Groups ( +CREATE TABLE `Groups` ( ID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, Name VARCHAR(64) NOT NULL, PRIMARY KEY (ID), @@ -211,7 +211,7 @@ CREATE TABLE PackageGroups ( GroupID INTEGER UNSIGNED NOT NULL, PRIMARY KEY (PackageID, GroupID), FOREIGN KEY (PackageID) REFERENCES Packages(ID) ON DELETE CASCADE, - FOREIGN KEY (GroupID) REFERENCES Groups(ID) ON DELETE CASCADE + FOREIGN KEY (GroupID) REFERENCES `Groups`(ID) ON DELETE CASCADE ) ENGINE = InnoDB; ---- diff --git a/upgrading/3.1.0.txt b/upgrading/3.1.0.txt index 2fc1614..e883a6c 100644 --- a/upgrading/3.1.0.txt +++ b/upgrading/3.1.0.txt @@ -7,7 +7,7 @@ ALTER TABLE Packages MODIFY Name VARCHAR(255) NOT NULL, MODIFY Version VARCHAR(255) NOT NULL DEFAULT ''; ALTER TABLE Licenses MODIFY Name VARCHAR(255) NOT NULL; -ALTER TABLE Groups MODIFY Name VARCHAR(255) NOT NULL; +ALTER TABLE `Groups` MODIFY Name VARCHAR(255) NOT NULL; ALTER TABLE PackageDepends MODIFY DepCondition VARCHAR(255); ALTER TABLE PackageRelations MODIFY RelCondition VARCHAR(255); ---- diff --git a/web/lib/aurjson.class.php b/web/lib/aurjson.class.php index c51e9c2..c275d21 100644 --- a/web/lib/aurjson.class.php +++ b/web/lib/aurjson.class.php @@ -284,10 +284,10 @@ private function get_extended_fields($pkgid, $base_id) { "LEFT JOIN RelationTypes " . "ON RelationTypes.ID = PackageRelations.RelTypeID " . "WHERE PackageRelations.PackageID = " . $pkgid . " " . - "UNION SELECT 'groups' AS Type, Groups.Name, '' AS Cond " . - "FROM Groups INNER JOIN PackageGroups " . + "UNION SELECT 'groups' AS Type, `Groups`.`Name`, '' AS Cond " . + "FROM `Groups` INNER JOIN PackageGroups " . "ON PackageGroups.PackageID = " . $pkgid . " " . - "AND PackageGroups.GroupID = Groups.ID " . + "AND PackageGroups.GroupID = `Groups`.ID " . "UNION SELECT 'license' AS Type, Licenses.Name, '' AS Cond " . "FROM Licenses INNER JOIN PackageLicenses " . "ON PackageLicenses.PackageID = " . $pkgid . " " . diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php index ced1f8e..00f0cc4 100644 --- a/web/lib/pkgfuncs.inc.php +++ b/web/lib/pkgfuncs.inc.php @@ -188,7 +188,7 @@ function pkg_groups($pkgid) { $pkgid = intval($pkgid); if ($pkgid > 0) { $dbh = DB::connect(); - $q = "SELECT g.Name FROM Groups g "; + $q = "SELECT g.Name FROM `Groups` g "; $q.= "INNER JOIN PackageGroups pg ON pg.GroupID = g.ID "; $q.= "WHERE pg.PackageID = ". $pkgid; $result = $dbh->query($q); -- 2.20.1
On 1/14/19 2:44 PM, Florian Pritz wrote:
Signed-off-by: Florian Pritz <bluewind@xinu.at> --- aurweb/git/update.py | 4 ++-- schema/aur-schema.sql | 4 ++-- upgrading/3.0.0.txt | 4 ++-- upgrading/3.1.0.txt | 2 +- web/lib/aurjson.class.php | 6 +++--- web/lib/pkgfuncs.inc.php | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) Merged to pu and the live instance is hotpatched.
-- Eli Schwartz Bug Wrangler and Trusted User
participants (2)
-
Eli Schwartz
-
Florian Pritz