Verified Commit 042f3f26 authored by Florian Pritz's avatar Florian Pritz Committed by Eli Schwartz
Browse files

Quote MySql 8.0 reserved keywords


Signed-off-by: Florian Pritz's avatarFlorian Pritz <bluewind@xinu.at>
Signed-off-by: Eli Schwartz's avatarEli Schwartz <eschwartz@archlinux.org>
parent f1d109e9
......@@ -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
......
......@@ -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;
......
......@@ -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;
----
......
......@@ -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);
----
......@@ -284,10 +284,10 @@ class AurJSON {
"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 . " " .
......
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment