Skip to content

Commit

Permalink
Support SQL::Identifier for Database#tables :schema option values on …
Browse files Browse the repository at this point in the history
…PostgreSQL
  • Loading branch information
jeremyevans committed Dec 20, 2023
1 parent 0b587bb commit c92feaf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
6 changes: 5 additions & 1 deletion lib/sequel/adapters/shared/postgres.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions spec/adapters/postgres_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit c92feaf

Please sign in to comment.