Module Sequel::Postgres
In: lib/sequel/adapters/postgres.rb
lib/sequel/adapters/shared/postgres.rb
lib/sequel/adapters/utils/pg_types.rb
lib/sequel/extensions/pg_row.rb
lib/sequel/extensions/pg_static_cache_updater.rb
lib/sequel/extensions/pg_inet.rb
lib/sequel/extensions/pg_row_ops.rb
lib/sequel/extensions/pg_hstore_ops.rb
lib/sequel/extensions/pg_enum.rb
lib/sequel/extensions/pg_inet_ops.rb
lib/sequel/extensions/pg_range.rb
lib/sequel/extensions/pg_array_ops.rb
lib/sequel/extensions/pg_json_ops.rb
lib/sequel/extensions/pg_interval.rb
lib/sequel/extensions/pg_range_ops.rb
lib/sequel/extensions/pg_array.rb
lib/sequel/extensions/pg_hstore.rb
lib/sequel/extensions/pg_loose_count.rb
lib/sequel/extensions/pg_json.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 :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. Overridable on a per instance basis via the :client_min_messages option.
force_standard_strings :Set to false to not force the use of standard strings. Overridable on a per instance basis via the :force_standard_strings option.

It is not recommened you use these module-level accessors. Instead, use the database option to make the setting per-Database.

All adapters that connect to PostgreSQL support the following option in addition to those mentioned above:

:search_path :Set the schema search_path for this Database‘s connections. Allows to to set which schemas do not need explicit qualification, and in which order to check the schemas when an unqualified object is referenced.

Methods

bytea   bytea   call   date   float   integer   mock_adapter_setup   prepare  

Classes and Modules

Module Sequel::Postgres::ArrayOpMethods
Module Sequel::Postgres::DatabaseMethods
Module Sequel::Postgres::DatasetMethods
Module Sequel::Postgres::EnumDatabaseMethods
Module Sequel::Postgres::HStoreOpMethods
Module Sequel::Postgres::InetDatabaseMethods
Module Sequel::Postgres::InetDatasetMethods
Module Sequel::Postgres::InetOpMethods
Module Sequel::Postgres::IntervalDatabaseMethods
Module Sequel::Postgres::IntervalDatasetMethods
Module Sequel::Postgres::JSONDatabaseMethods
Module Sequel::Postgres::JSONOpMethods
Module Sequel::Postgres::LooseCount
Module Sequel::Postgres::MockAdapterDatabaseMethods
Module Sequel::Postgres::PGRow
Module Sequel::Postgres::RangeOpMethods
Module Sequel::Postgres::StaticCacheUpdater
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::ExclusionConstraintViolation
Class Sequel::Postgres::HStore
Class Sequel::Postgres::HStoreOp
Class Sequel::Postgres::InetOp
Class Sequel::Postgres::JSONArray
Class Sequel::Postgres::JSONArrayBase
Class Sequel::Postgres::JSONBArray
Class Sequel::Postgres::JSONBHash
Class Sequel::Postgres::JSONBOp
Class Sequel::Postgres::JSONBaseOp
Class Sequel::Postgres::JSONHash
Class Sequel::Postgres::JSONHashBase
Class Sequel::Postgres::JSONOp
Class Sequel::Postgres::PGArray
Class Sequel::Postgres::PGRange
Class Sequel::Postgres::PGRowOp
Class Sequel::Postgres::RangeOp

Constants

CONVERTED_EXCEPTIONS = []   Array of exceptions that need to be converted. JDBC uses NativeExceptions, the native adapter uses PGError.
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
PG_NAMED_TYPES = {} unless defined?(PG_NAMED_TYPES)
CAST_JSON = '::json'.freeze
CAST_JSONB = '::jsonb'.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.
use_iso_date_format  [RW]  As an optimization, Sequel sets the date style to ISO, so that PostgreSQL provides the date in a known format that Sequel can parse faster. This can be turned off if you require a date style other than ISO.

Public Class methods

[Source]

    # File lib/sequel/adapters/shared/postgres.rb, line 40
40:     def self.mock_adapter_setup(db)
41:       db.instance_eval do
42:         @server_version = 90500
43:         initialize_postgres_adapter
44:         extend(MockAdapterDatabaseMethods)
45:       end
46:     end

Public Instance methods

[Source]

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

[Source]

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

Execute the given type of statement with the hash of values.

[Source]

     # File lib/sequel/adapters/postgres.rb, line 770
770:         def call(type, bind_vars=OPTS, *values, &block)
771:           ps = to_prepared_statement(type, values)
772:           ps.extend(BindArgumentMethods)
773:           ps.call(bind_vars, &block)
774:         end

[Source]

    # File lib/sequel/adapters/utils/pg_types.rb, line 29
29:       def date(s) ::Date.new(*s.split(DASH_STR).map(&:to_i)) end

[Source]

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

[Source]

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

Prepare the given type of statement with the given name, and store it in the database to be called later.

[Source]

     # File lib/sequel/adapters/postgres.rb, line 778
778:         def prepare(type, name=nil, *values)
779:           ps = to_prepared_statement(type, values)
780:           ps.extend(PreparedStatementMethods)
781:           if name
782:             ps.prepared_statement_name = name
783:             db.set_prepared_statement(name, ps)
784:           end
785:           ps
786:         end

[Validate]