diff options
author | Kegan Dougal <kegan@matrix.org> | 2015-03-02 10:16:24 +0000 |
---|---|---|
committer | Kegan Dougal <kegan@matrix.org> | 2015-03-02 10:16:24 +0000 |
commit | 3d73383d185b41b9986366da8123255e3a8ce1e0 (patch) | |
tree | 95fdacb46fc8315abfa946bb1979a33fd7bc37a8 /synapse/storage/_base.py | |
parent | PR tweaks: set earlier on and use 'as json' for compat (diff) | |
download | synapse-3d73383d185b41b9986366da8123255e3a8ce1e0.tar.xz |
Modify _simple_select_list to allow an empty WHERE clause. Use it for get_all_rooms and get_all_users.
Diffstat (limited to 'synapse/storage/_base.py')
-rw-r--r-- | synapse/storage/_base.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py index c98dd36aed..3725c9795d 100644 --- a/synapse/storage/_base.py +++ b/synapse/storage/_base.py @@ -450,7 +450,8 @@ class SQLBaseStore(object): Args: table : string giving the table name - keyvalues : dict of column names and values to select the rows with + keyvalues : dict of column names and values to select the rows with, + or None to not apply a WHERE clause. retcols : list of strings giving the names of the columns to return """ return self.runInteraction( @@ -469,13 +470,20 @@ class SQLBaseStore(object): keyvalues : dict of column names and values to select the rows with retcols : list of strings giving the names of the columns to return """ - sql = "SELECT %s FROM %s WHERE %s ORDER BY rowid asc" % ( - ", ".join(retcols), - table, - " AND ".join("%s = ?" % (k, ) for k in keyvalues) - ) + if keyvalues: + sql = "SELECT %s FROM %s WHERE %s ORDER BY rowid asc" % ( + ", ".join(retcols), + table, + " AND ".join("%s = ?" % (k, ) for k in keyvalues) + ) + txn.execute(sql, keyvalues.values()) + else: + sql = "SELECT %s FROM %s ORDER BY rowid asc" % ( + ", ".join(retcols), + table + ) + txn.execute(sql) - txn.execute(sql, keyvalues.values()) return self.cursor_to_dict(txn) def _simple_update_one(self, table, keyvalues, updatevalues, |