From c24e825c37d9f1f33fa4c1722c945aea26a1fc11 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 27 Dec 2013 13:40:27 -0500 Subject: [PATCH] - The firebird dialect will quote identifiers which begin with an underscore. Courtesy Treeve Jelbert. [ticket:2897] --- doc/build/changelog/changelog_08.rst | 8 ++++++++ lib/sqlalchemy/dialects/firebird/base.py | 1 + test/dialect/test_firebird.py | 9 +++++++++ 3 files changed, 18 insertions(+) diff --git a/doc/build/changelog/changelog_08.rst b/doc/build/changelog/changelog_08.rst index bd9a44532c..96e855ed68 100644 --- a/doc/build/changelog/changelog_08.rst +++ b/doc/build/changelog/changelog_08.rst @@ -11,6 +11,14 @@ .. changelog:: :version: 0.8.5 + .. change:: + :tags: bug, firebird + :versions: 0.9.0b2 + :tickets: 2897 + + The firebird dialect will quote identifiers which begin with an + underscore. Courtesy Treeve Jelbert. + .. change:: :tags: bug, firebird :versions: 0.9.0b2 diff --git a/lib/sqlalchemy/dialects/firebird/base.py b/lib/sqlalchemy/dialects/firebird/base.py index 734ae8e7b6..d83b4ee301 100644 --- a/lib/sqlalchemy/dialects/firebird/base.py +++ b/lib/sqlalchemy/dialects/firebird/base.py @@ -359,6 +359,7 @@ class FBIdentifierPreparer(sql.compiler.IdentifierPreparer): """Install Firebird specific reserved words.""" reserved_words = RESERVED_WORDS + illegal_initial_characters = compiler.ILLEGAL_INITIAL_CHARACTERS.union(['_']) def __init__(self, dialect): super(FBIdentifierPreparer, self).__init__(dialect, omit_schema=True) diff --git a/test/dialect/test_firebird.py b/test/dialect/test_firebird.py index 0a75cf971a..618819043c 100644 --- a/test/dialect/test_firebird.py +++ b/test/dialect/test_firebird.py @@ -352,6 +352,15 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): for type_, args, kw, res in columns: self.assert_compile(type_(*args, **kw), res) + def test_quoting_initial_chars(self): + self.assert_compile( + column("_somecol"), + '"_somecol"' + ) + self.assert_compile( + column("$somecol"), + '"$somecol"' + ) class TypesTest(fixtures.TestBase): __only_on__ = 'firebird' -- 2.47.3