From 715b70900e1cc7a46b76b68f417597ab314c79fb Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Tue, 22 Jan 2013 12:40:00 -0800 Subject: [PATCH] Make Dataset#schema_and_table handle literal strings correctly Previously, literal strings could be turned into non-literal strings and thus quoted literal by the identifier quoting code. --- lib/sequel/dataset/sql.rb | 2 +- spec/core/dataset_spec.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/sequel/dataset/sql.rb b/lib/sequel/dataset/sql.rb index e726f7c3a5..55df4e545d 100644 --- a/lib/sequel/dataset/sql.rb +++ b/lib/sequel/dataset/sql.rb @@ -654,7 +654,7 @@ def schema_and_table(table_name, sch=(db.default_schema if db)) when SQL::Identifier [sch, table_name.value.to_s] when String - [sch, table_name.to_s] + [sch, table_name] else raise Error, 'table_name should be a Symbol, SQL::QualifiedIdentifier, SQL::Identifier, or String' end diff --git a/spec/core/dataset_spec.rb b/spec/core/dataset_spec.rb index 993f56e9da..7cb242d102 100644 --- a/spec/core/dataset_spec.rb +++ b/spec/core/dataset_spec.rb @@ -4465,6 +4465,11 @@ class << Sequel @ds.schema_and_table('s').should == [nil, 's'] 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 @ds.schema_and_table(Sequel.identifier(:s)).should == [nil, 's'] end