Skip to content

Commit

Permalink
Make Dataset#schema_and_table handle literal strings correctly
Browse files Browse the repository at this point in the history
Previously, literal strings could be turned into non-literal
strings and thus quoted literal by the identifier quoting code.
  • Loading branch information
jeremyevans committed Jan 22, 2013
1 parent ed5ddae commit 715b709
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/sequel/dataset/sql.rb
Expand Up @@ -654,7 +654,7 @@ def schema_and_table(table_name, sch=(db.default_schema if db))
when SQL::Identifier when SQL::Identifier
[sch, table_name.value.to_s] [sch, table_name.value.to_s]
when String when String
[sch, table_name.to_s] [sch, table_name]
else else
raise Error, 'table_name should be a Symbol, SQL::QualifiedIdentifier, SQL::Identifier, or String' raise Error, 'table_name should be a Symbol, SQL::QualifiedIdentifier, SQL::Identifier, or String'
end end
Expand Down
5 changes: 5 additions & 0 deletions spec/core/dataset_spec.rb
Expand Up @@ -4465,6 +4465,11 @@ class << Sequel
@ds.schema_and_table('s').should == [nil, 's'] @ds.schema_and_table('s').should == [nil, 's']
end end


it "should correctly handle literal strings" do
s = Sequel.lit('s')
@ds.schema_and_table(s).last.should equal(s)
end

it "should correctly handle identifiers" do it "should correctly handle identifiers" do
@ds.schema_and_table(Sequel.identifier(:s)).should == [nil, 's'] @ds.schema_and_table(Sequel.identifier(:s)).should == [nil, 's']
end end
Expand Down

0 comments on commit 715b709

Please sign in to comment.