[aur-dev] [PATCH 5/8] git-interface: Do not use UNIX_TIMESTAMP
Lukas Fleischer
lfleischer at archlinux.org
Fri Aug 5 10:19:23 UTC 2016
Avoid using UNIX_TIMESTAMP which is not part of the SQL standard.
Retrieve the current UNIX time in Python and substitute it into the SQL
queries instead.
Signed-off-by: Lukas Fleischer <lfleischer at archlinux.org>
---
git-interface/git-serve.py | 5 +++--
git-interface/git-update.py | 6 ++++--
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/git-interface/git-serve.py b/git-interface/git-serve.py
index 6377ffc..d3a32c3 100755
--- a/git-interface/git-serve.py
+++ b/git-interface/git-serve.py
@@ -4,6 +4,7 @@ import os
import re
import shlex
import sys
+import time
import config
import db
@@ -58,10 +59,10 @@ def create_pkgbase(pkgbase, user):
if userid == 0:
die('{:s}: unknown user: {:s}'.format(action, user))
+ now = int(time.time())
cur = conn.execute("INSERT INTO PackageBases (Name, SubmittedTS, " +
"ModifiedTS, SubmitterUID, MaintainerUID) VALUES " +
- "(?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), ?, ?)",
- [pkgbase, userid, userid])
+ "(?, ?, ?, ?, ?)", [pkgbase, now, now, userid, userid])
pkgbase_id = cur.lastrowid
cur = conn.execute("INSERT INTO PackageNotifications " +
diff --git a/git-interface/git-update.py b/git-interface/git-update.py
index d6c9f10..2820720 100755
--- a/git-interface/git-update.py
+++ b/git-interface/git-update.py
@@ -5,6 +5,7 @@ import pygit2
import re
import subprocess
import sys
+import time
import srcinfo.parse
import srcinfo.utils
@@ -70,9 +71,10 @@ def save_metadata(metadata, conn, user):
user_id = int(cur.fetchone()[0])
# Update package base details and delete current packages.
- conn.execute("UPDATE PackageBases SET ModifiedTS = UNIX_TIMESTAMP(), " +
+ now = int(time.time())
+ conn.execute("UPDATE PackageBases SET ModifiedTS = ?, " +
"PackagerUID = ?, OutOfDateTS = NULL WHERE ID = ?",
- [user_id, pkgbase_id])
+ [now, user_id, pkgbase_id])
conn.execute("UPDATE PackageBases SET MaintainerUID = ? " +
"WHERE ID = ? AND MaintainerUID IS NULL",
[user_id, pkgbase_id])
--
2.9.2
More information about the aur-dev
mailing list