diff options
author | David Baker <dbkr@matrix.org> | 2014-09-03 18:25:17 +0100 |
---|---|---|
committer | David Baker <dbkr@matrix.org> | 2014-09-03 18:25:17 +0100 |
commit | d72ce4da64416eb10224e6a6b55aecdd27967b6b (patch) | |
tree | ec86c93b1ebaf0ebb11f9e9d2a5377f608ab98b2 /synapse/storage/_base.py | |
parent | Make registering and logging in with a threepid work in the webclient. (diff) | |
parent | Fix ban path (diff) | |
download | synapse-d72ce4da64416eb10224e6a6b55aecdd27967b6b.tar.xz |
Merge branch 'develop' of github.com:matrix-org/synapse into develop
Conflicts: synapse/http/client.py
Diffstat (limited to 'synapse/storage/_base.py')
-rw-r--r-- | synapse/storage/_base.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py index 33d56f47ce..bae50e7d1f 100644 --- a/synapse/storage/_base.py +++ b/synapse/storage/_base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2014 matrix.org +# Copyright 2014 OpenMarket Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -79,19 +79,21 @@ class SQLBaseStore(object): # "Simple" SQL API methods that operate on a single table with no JOINs, # no complex WHERE clauses, just a dict of values for columns. - def _simple_insert(self, table, values): + def _simple_insert(self, table, values, or_replace=False): """Executes an INSERT query on the named table. Args: table : string giving the table name values : dict of new column names and values for them + or_replace : bool; if True performs an INSERT OR REPLACE """ return self._db_pool.runInteraction( - self._simple_insert_txn, table, values, + self._simple_insert_txn, table, values, or_replace=or_replace ) - def _simple_insert_txn(self, txn, table, values): - sql = "INSERT INTO %s (%s) VALUES(%s)" % ( + def _simple_insert_txn(self, txn, table, values, or_replace=False): + sql = "%s INTO %s (%s) VALUES(%s)" % ( + ("INSERT OR REPLACE" if or_replace else "INSERT"), table, ", ".join(k for k in values), ", ".join("?" for k in values) |