summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndi Albrecht <albrecht.andi@gmail.com>2010-11-21 19:42:57 +0100
committerAndi Albrecht <albrecht.andi@gmail.com>2010-11-21 19:42:57 +0100
commita0bafb0929ce7cee6ce38b368d96f3ae0ae98b25 (patch)
treeb83aa1f7b8502a20220571a77153b087f3531146
parentb56308b44ac5f60b757c576fdea4f91c5e215898 (diff)
downloadsqlparse-a0bafb0929ce7cee6ce38b368d96f3ae0ae98b25.tar.gz
Ignore identifiers in double-quotes when changing identifier case (fixes issue21).
-rw-r--r--CHANGES1
-rw-r--r--sqlparse/filters.py6
-rw-r--r--tests/test_format.py2
3 files changed, 8 insertions, 1 deletions
diff --git a/CHANGES b/CHANGES
index 44e9328..dcd1e62 100644
--- a/CHANGES
+++ b/CHANGES
@@ -9,6 +9,7 @@ Bug Fixes
* Fixed an issue with trailing whitespaces (reported by Kris).
* Better detection of escaped single quotes (issue13, reported by
Martin Brochhaus, patch by bluemaro with test case by Dan Carley).
+ * Ignore identifier in double-quotes when changing cases (issue 21).
* Lots of minor fixes targeting encoding, indentation, statement
parsing and more (issues 12, 14, 15, 16, 19).
* Code cleanup with a pinch of refactoring.
diff --git a/sqlparse/filters.py b/sqlparse/filters.py
index a3ae192..9d1e0b9 100644
--- a/sqlparse/filters.py
+++ b/sqlparse/filters.py
@@ -45,6 +45,12 @@ class KeywordCaseFilter(_CaseFilter):
class IdentifierCaseFilter(_CaseFilter):
ttype = (T.Name, T.String.Symbol)
+ def process(self, stack, stream):
+ for ttype, value in stream:
+ if ttype in self.ttype and not value.strip()[0] == '"':
+ value = self.convert(value)
+ yield ttype, value
+
# ----------------------
# statement process
diff --git a/tests/test_format.py b/tests/test_format.py
index 32e8bef..b56ceaf 100644
--- a/tests/test_format.py
+++ b/tests/test_format.py
@@ -30,7 +30,7 @@ class TestFormat(TestCaseBase):
identifier_case='foo')
sql = 'select * from "foo"."bar"'
res = sqlparse.format(sql, identifier_case="upper")
- self.ndiffAssertEqual(res, 'select * from "FOO"."BAR"')
+ self.ndiffAssertEqual(res, 'select * from "foo"."bar"')
def test_strip_comments_single(self):
sql = 'select *-- statement starts here\nfrom foo'