Module | Sequel::Postgres |
In: |
lib/sequel/adapters/postgres.rb
lib/sequel/adapters/shared/postgres.rb |
Top level module for holding all PostgreSQL-related modules and classes for Sequel. There are a few module level accessors that are added via metaprogramming. These are:
Changes in these settings only affect future connections. To make sure that they are applied, they should generally be called right after the Database object is instantiated and before a connection is actually made. For example, to use whatever the server defaults are:
DB = Sequel.postgres(...) Sequel::Postgres.client_min_messages = nil Sequel::Postgres.force_standard_strings = false Sequel::Postgres.use_iso_date_format = false # A connection to the server is not made until here DB[:t].all
The reason they can‘t be done earlier is that the Sequel::Postgres module is not loaded until a Database object which uses PostgreSQL is created.
TYPE_TRANSLATOR | = | tt = Class.new do def boolean(s) s == 't' end | ||
CONVERTED_EXCEPTIONS | = | [] | Array of exceptions that need to be converted. JDBC uses NativeExceptions, the native adapter uses PGError. | |
SELECT_PK | = | proc do |schema, table| <<-end_sql SELECT pg_attribute.attname FROM pg_class, pg_attribute, pg_index, pg_namespace WHERE pg_class.oid = pg_attribute.attrelid AND pg_class.relnamespace = pg_namespace.oid AND pg_class.oid = pg_index.indrelid AND pg_index.indkey[0] = pg_attribute.attnum AND pg_index.indisprimary = 't' #{"AND pg_namespace.nspname = '#{schema}'" if schema} AND pg_class.relname = '#{table}' end_sql |
client_min_messages | [RW] | By default, Sequel sets the minimum level of log messages sent to the client to WARNING, where PostgreSQL uses a default of NOTICE. This is to avoid a lot of mostly useless messages when running migrations, such as a couple of lines for every serial primary key field. |
force_standard_strings | [RW] | By default, Sequel forces the use of standard strings, so that ’\’ is interpreted as \ and not \. While PostgreSQL defaults to interpreting plain strings as extended strings, this will change in a future version of PostgreSQL. Sequel assumes that SQL standard strings will be used. |
# File lib/sequel/adapters/postgres.rb, line 93 93: def bytea(s) ::Sequel::SQL::Blob.new(Adapter.unescape_bytea(s)) end
# File lib/sequel/adapters/postgres.rb, line 98 98: def date_iso(s) ::Date.new(*s.split("-").map{|x| x.to_i}) end