Skip to content

Commit

Permalink
* Allow arbitrary sets of nested parens around values. Thanks to _W_ …
Browse files Browse the repository at this point in the history
…in #sql
  • Loading branch information
smtlaissezfaire committed Jan 5, 2009
1 parent f09755b commit 81404d0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/guillotine/parser/primitives.treetop
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@ module Guillotine
module Parser
grammar SQLPrimitives
rule primitive
open_parens primitive close_parens {
def eval
simple_primitive.eval
end
}
/
simple_primitive
end

rule open_parens
'('
end

rule close_parens
')'
end

rule simple_primitive
datetime / date / boolean / quoted_string / backtick_string / number / string
end

Expand Down
8 changes: 8 additions & 0 deletions spec/guillotine/parser/sql_select_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ module Parser
select = parse_and_eval_with_upcasing(first_statement)
select.where.key.should equal(:foo)
end

it "should parse a paren around a value" do
parse("SELECT * FROM foo WHERE id = (7)").should_not be_nil
end

it "should parse two parens around a value" do
parse("SELECT * FROM foo WHERE id = ((7))").should_not be_nil
end
end
end
end

0 comments on commit 81404d0

Please sign in to comment.