diff --git a/CHANGELOG b/CHANGELOG index 0802624df..c452e826f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ === master +* Support SQL::Identifier for Database#tables :schema option values on PostgreSQL (jeremyevans) + * Support generating rcte queries using UNION or UNION ALL in the rcte plugin (jonathanfrias) (#2107) * Make Database#table_exists? on PostgreSQL handle lock or statement timeout errors as evidence the table exists (jeremyevans) (#2106) diff --git a/lib/sequel/adapters/shared/postgres.rb b/lib/sequel/adapters/shared/postgres.rb index a2e5a9170..3300f9a7f 100644 --- a/lib/sequel/adapters/shared/postgres.rb +++ b/lib/sequel/adapters/shared/postgres.rb @@ -1513,7 +1513,11 @@ def drop_view_sql(name, opts=OPTS) # currently visible schemas. def filter_schema(ds, opts) expr = if schema = opts[:schema] - schema.to_s + if schema.is_a?(SQL::Identifier) + schema.value.to_s + else + schema.to_s + end else Sequel.function(:any, Sequel.function(:current_schemas, false)) end diff --git a/spec/adapters/postgres_spec.rb b/spec/adapters/postgres_spec.rb index 43f1c0313..311746194 100644 --- a/spec/adapters/postgres_spec.rb +++ b/spec/adapters/postgres_spec.rb @@ -2508,6 +2508,9 @@ def @Member.name; :Member; end @d.create_schema(:sequel) @d.create_schema(:sequel, :if_not_exists=>true) if @d.server_version >= 90300 @d.create_table(Sequel[:sequel][:test]){Integer :a} + @d.tables(:schema=>:sequel).must_equal [:test] + @d.tables(:schema=>'sequel').must_equal [:test] + @d.tables(:schema=>Sequel[:sequel]).must_equal [:test] @d.drop_schema(:sequel, :if_exists=>true, :cascade=>true) end