diff options
author | Martin Pihlak | 2012-08-16 09:47:10 +0000 |
---|---|---|
committer | Martin Pihlak | 2012-08-16 09:47:10 +0000 |
commit | e1c22bd6d598dcf86a2a930bd19904e330b085b6 (patch) | |
tree | c32d23315afe3d3c15b24f62dcc212df03e34671 /python/skytools/dbstruct.py | |
parent | 37e91db8fb3a1fcd9a7a54934a2e882a5a953d0c (diff) | |
parent | f8d90af0912db0a2ed29aa5e8fb912be3ab309a6 (diff) |
Merge branch 'master' of internal-git:/git/dba/skytools-3
Diffstat (limited to 'python/skytools/dbstruct.py')
-rw-r--r-- | python/skytools/dbstruct.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/python/skytools/dbstruct.py b/python/skytools/dbstruct.py index 5311889a..e1a7012c 100644 --- a/python/skytools/dbstruct.py +++ b/python/skytools/dbstruct.py @@ -192,10 +192,16 @@ class TRule(TElem): sql = self.defn table = self.table_name else: + idrx = r'''([a-z0-9._]+|"([^"]+|"")+")+''' # fixme: broken / quoting - rx = r"\bTO[ ][a-z0-9._]+[ ]DO[ ]" - pnew = "TO %s DO " % new_table_name - sql = rx_replace(rx, self.defn, pnew) + rx = r"\bTO[ ]" + idrx + rc = re.compile(rx, re.X) + m = rc.search(self.defn) + if not m: + raise Exception('Cannot find table name in rule') + old_tbl = m.group(1) + new_tbl = quote_fqident(new_table_name) + sql = self.defn.replace(old_tbl, new_tbl) table = new_table_name if self.enabled != 'O': # O - rule fires in origin and local modes |