From 7243fe1858ab1673976cecc0ae06ddeaa3095678 Mon Sep 17 00:00:00 2001 From: Thomas Kern Date: Thu, 18 Oct 2012 14:53:49 +0200 Subject: [PATCH] Add parentheses in WHERE clause of every SELECT statement Adding parentheses to the WHERE clauses allows the usage of multi-column primary keys/foreign keys. E.g.: columns aid and aid2 are the primary keys and are queried in the foreign table. SELECT * FROM tabA WHERE aid = 5 AND aid2 = 7 OR aid = 5 AND aid2 = 8 OR aid=9 AND aid10; The parentheses fixes this: SELECT * FROM tabA WHERE (aid = 5 AND aid2 = 7) OR (aid = 5 AND aid2 = 8) OR (aid=9 AND aid10); --- mysqlpartialdump.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysqlpartialdump.py b/mysqlpartialdump.py index 479849e..5373317 100755 --- a/mysqlpartialdump.py +++ b/mysqlpartialdump.py @@ -271,8 +271,8 @@ def _do_follows(self, to_follow): args += [val for val in value] debug('Clauses to follow: %s'%clauses) info('Following %s with %s'%(table, values_to_follow)) - where = " OR ".join(clauses) - self._get_table(table, where, args) + where = ") OR (".join(clauses) + self._get_table(table, "(" + where + ")", args) del(follow_sets[col_names]) def _get_pk_value(self, table_name, row):