Skip to content

Commit 99611df

Browse files
author
Dray Lacy
committed
Added quoted identifiers.
1 parent abfdc87 commit 99611df

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

lib/sql/parser.rex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ rule
7777
, { [:comma, text] }
7878
7979
# identifier
80+
`{IDENT}` { [:identifier, text[1..-2]] }
8081
{IDENT} { [:identifier, text] }
8182
8283
---- header ----

lib/sql/parser.rex.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ def scan_evaluate( str )
203203
when (text = ss.scan(/,/))
204204
@rex_tokens.push action { [:comma, text] }
205205

206+
when (text = ss.scan(/`\w+`/))
207+
@rex_tokens.push action { [:identifier, text[1..-2]] }
208+
206209
when (text = ss.scan(/\w+/))
207210
@rex_tokens.push action { [:identifier, text] }
208211

test/test_parser.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ def test_numeric_value_expression
193193
assert_understands 'SELECT (1 - 2)'
194194
end
195195

196+
def test_quoted_identifier
197+
assert_sql 'SELECT a', 'SELECT `a`'
198+
end
199+
196200
def test_date
197201
assert_sql "SELECT DATE '2008-07-11'", 'SELECT DATE "2008-07-11"'
198202
assert_understands "SELECT DATE '2008-07-11'"

0 commit comments

Comments
 (0)