diff options
author | Erik Johnston <erik@matrix.org> | 2015-05-11 10:58:36 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-05-11 11:24:01 +0100 |
commit | cd525c0f5a8a973626c81ccd158bf0f9586dc320 (patch) | |
tree | 63507432e04aa17b10f9ed42ba1639859cc514ee /synapse/storage/push_rule.py | |
parent | Merge pull request #145 from matrix-org/hotfixes-v0.9.0-r3 (diff) | |
download | synapse-cd525c0f5a8a973626c81ccd158bf0f9586dc320.tar.xz |
push_rules table expects an 'id' field
Diffstat (limited to 'synapse/storage/push_rule.py')
-rw-r--r-- | synapse/storage/push_rule.py | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/synapse/storage/push_rule.py b/synapse/storage/push_rule.py index da23c1a114..6811566e83 100644 --- a/synapse/storage/push_rule.py +++ b/synapse/storage/push_rule.py @@ -120,6 +120,7 @@ class PushRuleStore(SQLBaseStore): del new_rule['after'] new_rule['priority_class'] = priority_class new_rule['user_name'] = user_name + new_rule['id'] = self._push_rule_id_gen.get_next_txn(txn) # check if the priority before/after is free new_rule_priority = base_rule_priority @@ -153,12 +154,11 @@ class PushRuleStore(SQLBaseStore): txn.execute(sql, (user_name, priority_class, new_rule_priority)) - # now insert the new rule - sql = "INSERT INTO "+PushRuleTable.table_name+" (" - sql += ",".join(new_rule.keys())+") VALUES (" - sql += ", ".join(["?" for _ in new_rule.keys()])+")" - - txn.execute(sql, new_rule.values()) + self._simple_insert_txn( + txn, + table=PushRuleTable.table_name, + values=new_rule, + ) def _add_push_rule_highest_priority_txn(self, txn, user_name, priority_class, **kwargs): @@ -177,17 +177,16 @@ class PushRuleStore(SQLBaseStore): # and insert the new rule new_rule = copy.copy(kwargs) - if 'id' in new_rule: - del new_rule['id'] + new_rule['id'] = self._push_rule_id_gen.get_next_txn(txn) new_rule['user_name'] = user_name new_rule['priority_class'] = priority_class new_rule['priority'] = new_prio - sql = "INSERT INTO "+PushRuleTable.table_name+" (" - sql += ",".join(new_rule.keys())+") VALUES (" - sql += ", ".join(["?" for _ in new_rule.keys()])+")" - - txn.execute(sql, new_rule.values()) + self._simple_insert_txn( + txn, + table=PushRuleTable.table_name, + values=new_rule, + ) @defer.inlineCallbacks def delete_push_rule(self, user_name, rule_id): |