Read about our upcoming Code of Conduct on this issue

Commit 6f9ebdbd authored by Raphaël Gomès's avatar Raphaël Gomès
Browse files

python3: mark all SQL queries as raw strings

parent 16c1398b0063
......@@ -262,12 +262,12 @@ def _obshashrange(repo, rangeid):
### sqlite caching
_sqliteschema = [
"""CREATE TABLE obshashrange(rev INTEGER NOT NULL,
r"""CREATE TABLE obshashrange(rev INTEGER NOT NULL,
idx INTEGER NOT NULL,
obshash BLOB NOT NULL,
PRIMARY KEY(rev, idx));""",
"CREATE INDEX range_index ON obshashrange(rev, idx);",
"""CREATE TABLE meta(schemaversion INTEGER NOT NULL,
r"CREATE INDEX range_index ON obshashrange(rev, idx);",
r"""CREATE TABLE meta(schemaversion INTEGER NOT NULL,
tiprev INTEGER NOT NULL,
tipnode BLOB NOT NULL,
nbobsmarker INTEGER NOT NULL,
......@@ -275,17 +275,17 @@ _sqliteschema = [
obskey BLOB NOT NULL
);""",
]
_queryexist = "SELECT name FROM sqlite_master WHERE type='table' AND name='meta';"
_clearmeta = """DELETE FROM meta;"""
_newmeta = """INSERT INTO meta (schemaversion, tiprev, tipnode, nbobsmarker, obssize, obskey)
_queryexist = r"SELECT name FROM sqlite_master WHERE type='table' AND name='meta';"
_clearmeta = r"""DELETE FROM meta;"""
_newmeta = r"""INSERT INTO meta (schemaversion, tiprev, tipnode, nbobsmarker, obssize, obskey)
VALUES (?,?,?,?,?,?);"""
_updateobshash = "INSERT INTO obshashrange(rev, idx, obshash) VALUES (?,?,?);"
_querymeta = "SELECT schemaversion, tiprev, tipnode, nbobsmarker, obssize, obskey FROM meta;"
_queryobshash = "SELECT obshash FROM obshashrange WHERE (rev = ? AND idx = ?);"
_query_max_stored = "SELECT MAX(rev) FROM obshashrange"
_updateobshash = r"INSERT INTO obshashrange(rev, idx, obshash) VALUES (?,?,?);"
_querymeta = r"SELECT schemaversion, tiprev, tipnode, nbobsmarker, obssize, obskey FROM meta;"
_queryobshash = r"SELECT obshash FROM obshashrange WHERE (rev = ? AND idx = ?);"
_query_max_stored = r"SELECT MAX(rev) FROM obshashrange"
_reset = "DELETE FROM obshashrange;"
_delete = "DELETE FROM obshashrange WHERE (rev = ? AND idx = ?);"
_reset = r"DELETE FROM obshashrange;"
_delete = r"DELETE FROM obshashrange WHERE (rev = ? AND idx = ?);"
def _affectedby(repo, markers):
"""return all nodes whose relevant set is affected by this changeset
......
......@@ -120,10 +120,10 @@ class stablerangeondiskbase(stablerange.stablerangecached,
#############################
_sqliteschema = [
"""CREATE TABLE range(rev INTEGER NOT NULL,
r"""CREATE TABLE range(rev INTEGER NOT NULL,
idx INTEGER NOT NULL,
PRIMARY KEY(rev, idx));""",
"""CREATE TABLE subranges(listidx INTEGER NOT NULL,
r"""CREATE TABLE subranges(listidx INTEGER NOT NULL,
suprev INTEGER NOT NULL,
supidx INTEGER NOT NULL,
subrev INTEGER NOT NULL,
......@@ -132,37 +132,37 @@ _sqliteschema = [
FOREIGN KEY (suprev, supidx) REFERENCES range(rev, idx),
FOREIGN KEY (subrev, subidx) REFERENCES range(rev, idx)
);""",
"CREATE INDEX subranges_index ON subranges (suprev, supidx);",
"CREATE INDEX superranges_index ON subranges (subrev, subidx);",
"CREATE INDEX range_index ON range (rev, idx);",
"""CREATE TABLE meta(schemaversion INTEGER NOT NULL,
r"CREATE INDEX subranges_index ON subranges (suprev, supidx);",
r"CREATE INDEX superranges_index ON subranges (subrev, subidx);",
r"CREATE INDEX range_index ON range (rev, idx);",
r"""CREATE TABLE meta(schemaversion INTEGER NOT NULL,
tiprev INTEGER NOT NULL,
tipnode BLOB NOT NULL
);""",
]
_newmeta = "INSERT INTO meta (schemaversion, tiprev, tipnode) VALUES (?,?,?);"
_updatemeta = "UPDATE meta SET tiprev = ?, tipnode = ?;"
_updaterange = "INSERT INTO range(rev, idx) VALUES (?,?);"
_updatesubranges = """INSERT
_newmeta = r"INSERT INTO meta (schemaversion, tiprev, tipnode) VALUES (?,?,?);"
_updatemeta = r"UPDATE meta SET tiprev = ?, tipnode = ?;"
_updaterange = r"INSERT INTO range(rev, idx) VALUES (?,?);"
_updatesubranges = r"""INSERT
INTO subranges(listidx, suprev, supidx, subrev, subidx)
VALUES (?,?,?,?,?);"""
_queryexist = "SELECT name FROM sqlite_master WHERE type='table' AND name='meta';"
_querymeta = "SELECT schemaversion, tiprev, tipnode FROM meta;"
_queryrange = "SELECT * FROM range WHERE (rev = ? AND idx = ?);"
_querysubranges = """SELECT subrev, subidx
_queryexist = r"SELECT name FROM sqlite_master WHERE type='table' AND name='meta';"
_querymeta = r"SELECT schemaversion, tiprev, tipnode FROM meta;"
_queryrange = r"SELECT * FROM range WHERE (rev = ? AND idx = ?);"
_querysubranges = r"""SELECT subrev, subidx
FROM subranges
WHERE (suprev = ? AND supidx = ?)
ORDER BY listidx;"""
_querysuperrangesmain = """SELECT DISTINCT suprev, supidx
_querysuperrangesmain = r"""SELECT DISTINCT suprev, supidx
FROM subranges
WHERE %s;"""
_querysuperrangesbody = '(subrev = %d and subidx = %d)'
_querysuperrangesbody = r'(subrev = %d and subidx = %d)'
def _make_querysuperranges(ranges):
# building a tree of OR would allow for more ranges
body = ' OR '.join(_querysuperrangesbody % r for r in ranges)
body = r' OR '.join(_querysuperrangesbody % r for r in ranges)
return _querysuperrangesmain % body
class stablerangesqlbase(stablerange.stablerangecached):
......
Markdown is supported
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