Module Sequel::Postgres
In: lib/sequel/adapters/utils/pg_types.rb
lib/sequel/adapters/shared/postgres.rb
lib/sequel/adapters/postgres.rb
lib/sequel/extensions/pg_array_ops.rb
lib/sequel/extensions/pg_range.rb
lib/sequel/extensions/pg_hstore_ops.rb
lib/sequel/extensions/pg_row_ops.rb
lib/sequel/extensions/pg_interval.rb
lib/sequel/extensions/pg_hstore.rb
lib/sequel/extensions/pg_row.rb
lib/sequel/extensions/pg_auto_parameterize.rb
lib/sequel/extensions/pg_array.rb
lib/sequel/extensions/pg_range_ops.rb
lib/sequel/extensions/pg_json.rb
lib/sequel/extensions/pg_inet.rb
lib/sequel/extensions/pg_statement_cache.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:

  • client_min_messages (only available when using the native adapter) - Change the minimum level of messages that PostgreSQL will send to the the client. The PostgreSQL default is NOTICE, the Sequel default is WARNING. Set to nil to not change the server default.
  • force_standard_strings - Set to false to not force the use of standard strings
  • use_iso_date_format (only available when using the native adapter) - Set to false to not change the date format to ISO. This disables one of Sequel‘s optimizations.

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.

Methods

bytea   bytea   date   float   integer  

Classes and Modules

Module Sequel::Postgres::ArrayOpMethods
Module Sequel::Postgres::AutoParameterize
Module Sequel::Postgres::DatabaseMethods
Module Sequel::Postgres::DatasetMethods
Module Sequel::Postgres::HStoreOpMethods
Module Sequel::Postgres::InetDatabaseMethods
Module Sequel::Postgres::InetDatasetMethods
Module Sequel::Postgres::IntervalDatabaseMethods
Module Sequel::Postgres::IntervalDatasetMethods
Module Sequel::Postgres::JSONDatabaseMethods
Module Sequel::Postgres::PGRow
Module Sequel::Postgres::RangeOpMethods
Module Sequel::Postgres::StatementCache
Class Sequel::Postgres::Adapter
Class Sequel::Postgres::AlterTableGenerator
Class Sequel::Postgres::ArrayOp
Class Sequel::Postgres::CreateTableGenerator
Class Sequel::Postgres::Database
Class Sequel::Postgres::Dataset
Class Sequel::Postgres::HStore
Class Sequel::Postgres::HStoreOp
Class Sequel::Postgres::JSONArray
Class Sequel::Postgres::JSONHash
Class Sequel::Postgres::PGArray
Class Sequel::Postgres::PGRange
Class Sequel::Postgres::PGRowOp
Class Sequel::Postgres::RangeOp

Constants

NAN = 0.0/0.0
PLUS_INFINITY = 1.0/0.0
MINUS_INFINITY = -1.0/0.0
NAN_STR = 'NaN'.freeze
PLUS_INFINITY_STR = 'Infinity'.freeze
MINUS_INFINITY_STR = '-Infinity'.freeze
TRUE_STR = 't'.freeze
DASH_STR = '-'.freeze
TYPE_TRANSLATOR = tt = Class.new do def boolean(s) s == TRUE_STR end
CONVERTED_EXCEPTIONS = []   Array of exceptions that need to be converted. JDBC uses NativeExceptions, the native adapter uses PGError.
PG_NAMED_TYPES = {} unless defined?(PG_NAMED_TYPES)
CAST_JSON = '::json'.freeze

Attributes

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 <9.1 defaults to interpreting plain strings, newer versions use standard strings by default. Sequel assumes that SQL standard strings will be used. Setting this to false means Sequel will use the database‘s default.

Public Instance methods

[Source]

    # File lib/sequel/adapters/postgres.rb, line 92
92:       def bytea(s) ::Sequel::SQL::Blob.new(Adapter.unescape_bytea(s)) end

[Source]

    # File lib/sequel/adapters/utils/pg_types.rb, line 28
28:       def bytea(str)
29:         str = if str =~ /\A\\x/
30:           # PostgreSQL 9.0+ bytea hex format
31:           str[2..-1].gsub(/(..)/){|s| s.to_i(16).chr}
32:         else
33:           # Historical PostgreSQL bytea escape format
34:           str.gsub(/\\(\\|'|[0-3][0-7][0-7])/) {|s|
35:             if s.size == 2 then s[1,1] else s[1,3].oct.chr end
36:           }
37:         end
38:         ::Sequel::SQL::Blob.new(str)
39:       end

[Source]

    # File lib/sequel/adapters/utils/pg_types.rb, line 27
27:       def date(s) ::Date.new(*s.split(DASH_STR).map{|x| x.to_i}) end

[Source]

    # File lib/sequel/adapters/utils/pg_types.rb, line 15
15:       def float(s) 
16:         case s
17:         when NAN_STR
18:           NAN
19:         when PLUS_INFINITY_STR
20:           PLUS_INFINITY
21:         when MINUS_INFINITY_STR
22:           MINUS_INFINITY
23:         else
24:           s.to_f 
25:         end
26:       end

[Source]

    # File lib/sequel/adapters/utils/pg_types.rb, line 14
14:       def integer(s) s.to_i end

[Validate]