From: Mike Bayer Date: Mon, 4 Feb 2008 21:47:42 +0000 (+0000) Subject: - add dummy column to appease older SQLite verisons in unicode.py X-Git-Tag: rel_0_4_3~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb1dd85dcc123a60ab5fdc0d3a61641703d91948;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - add dummy column to appease older SQLite verisons in unicode.py - add test "escape_literal_column" comiler method to start addressing literal '%' character --- diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 71bfd17658..5cfb42a631 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -269,16 +269,20 @@ class DefaultCompiler(engine.Compiled): return None elif column.table is None or not column.table.named_with_column: if getattr(column, "is_literal", False): - return name + return self.escape_literal_column(name) else: return self.preparer.quote(column, name) else: if getattr(column, "is_literal", False): - return self.preparer.quote(column.table, ANONYMOUS_LABEL.sub(self._process_anon, column.table.name)) + "." + name + return self.preparer.quote(column.table, ANONYMOUS_LABEL.sub(self._process_anon, column.table.name)) + "." + self.escape_literal_column(name) else: return self.preparer.quote(column.table, ANONYMOUS_LABEL.sub(self._process_anon, column.table.name)) + "." + self.preparer.quote(column, name) + def escape_literal_column(self, text): + """provide escaping for the literal_column() construct.""" + return re.sub('%', '%%', text) + def visit_fromclause(self, fromclause, **kwargs): return fromclause.name diff --git a/test/sql/unicode.py b/test/sql/unicode.py index 98a2b6aa2b..6f035f2bfc 100644 --- a/test/sql/unicode.py +++ b/test/sql/unicode.py @@ -116,7 +116,9 @@ class EscapesDefaultsTest(testing.PersistTest): def test_default_exec(self): metadata = MetaData(testing.db) t1 = Table('t1', metadata, - Column(u'special_col', Integer, Sequence('special_col'), primary_key=True)) + Column(u'special_col', Integer, Sequence('special_col'), primary_key=True), + Column('data', String(50)) # to appease SQLite without DEFAULT VALUES + ) t1.create() try: