Module: Sequel::Postgres

Defined in:
lib/sequel/adapters/shared/postgres.rb,
lib/sequel/adapters/postgres.rb,
lib/sequel/extensions/pg_row.rb,
lib/sequel/extensions/pg_enum.rb,
lib/sequel/extensions/pg_inet.rb,
lib/sequel/extensions/pg_json.rb,
lib/sequel/extensions/pg_array.rb,
lib/sequel/extensions/pg_range.rb,
lib/sequel/extensions/pg_hstore.rb,
lib/sequel/extensions/pg_row_ops.rb,
lib/sequel/extensions/pg_inet_ops.rb,
lib/sequel/extensions/pg_interval.rb,
lib/sequel/extensions/pg_json_ops.rb,
lib/sequel/extensions/pg_array_ops.rb,
lib/sequel/extensions/pg_range_ops.rb,
lib/sequel/extensions/pg_hstore_ops.rb,
lib/sequel/extensions/pg_loose_count.rb,
lib/sequel/extensions/pg_static_cache_updater.rb

Overview

Top level module for holding all PostgreSQL-related modules and classes for Sequel. All adapters that connect to PostgreSQL support the following options:

: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.

: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.

Defined Under Namespace

Modules: ArrayOpMethods, DatabaseMethods, DatasetMethods, EnumDatabaseMethods, HStoreOpMethods, InetDatabaseMethods, InetDatasetMethods, InetOpMethods, IntervalDatabaseMethods, IntervalDatasetMethods, JSONDatabaseMethods, JSONOpMethods, LooseCount, MockAdapterDatabaseMethods, PGRow, RangeOpMethods, StaticCacheUpdater Classes: Adapter, AlterTableGenerator, ArrayOp, CreateTableGenerator, Database, Dataset, ExclusionConstraintViolation, HStore, HStoreOp, InetOp, JSONArray, JSONArrayBase, JSONBArray, JSONBHash, JSONBOp, JSONBaseOp, JSONHash, JSONHashBase, JSONOp, PGArray, PGRange, PGRowOp, RangeOp

Constant Summary collapse

TYPE_CONVERTOR =

SEQUEL5: Remove

Class.new do
  def bytea(s) ::Sequel::SQL::Blob.new(Adapter.unescape_bytea(s)) end
end.new
CAST_JSON =
'::json'.freeze
CAST_JSONB =
'::jsonb'.freeze
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 == 't' end
  def integer(s) s.to_i end
  def float(s) 
    case s
    when 'NaN'
      NAN
    when 'Infinity'
      PLUS_INFINITY
    when '-Infinity'
      MINUS_INFINITY
    else
      s.to_f 
    end
  end
  def date(s) ::Date.new(*s.split('-').map(&:to_i)) end
  def bytea(str)
    str = if str =~ /\A\\x/
      # PostgreSQL 9.0+ bytea hex format
      str[2..-1].gsub(/(..)/){|s| s.to_i(16).chr}
    else
      # Historical PostgreSQL bytea escape format
      str.gsub(/\\(\\|'|[0-3][0-7][0-7])/) {|s|
        if s.size == 2 then s[1,1] else s[1,3].oct.chr end
      }
    end
    ::Sequel::SQL::Blob.new(str)
  end
end.new
STRING_TYPES =

Type OIDs for string types used by PostgreSQL. These types don’t have conversion procs associated with them (since the data is already in the form of a string).

[18, 19, 25, 1042, 1043]
PG_NAMED_TYPES =

Hash with type name strings/symbols and callable values for converting PostgreSQL types. Non-builtin types that don’t have fixed numbers should use this to register conversion procs.

{}
PG_NAMED__TYPES =
PG_NAMED_TYPES
PG_TYPES =

Hash with integer keys and callable values for converting PostgreSQL types.

{}
PG__TYPES =
PG_TYPES
CONVERTED_EXCEPTIONS =
[]

Class Method Summary collapse

Class Method Details

.client_min_messagesObject



129
130
131
132
# File 'lib/sequel/adapters/shared/postgres.rb', line 129

def client_min_messages
  Sequel::Deprecation.deprecate("Sequel::Postgres.client_min_messages", "Use the :client_min_messages Database option instead")
  @client_min_messages
end

.client_min_messages=(v) ⇒ Object



133
134
135
136
# File 'lib/sequel/adapters/shared/postgres.rb', line 133

def client_min_messages=(v)
  Sequel::Deprecation.deprecate("Sequel::Postgres.client_min_messages=", "Use the :client_min_messages Database option instead")
  @client_min_messages = v
end

.force_standard_stringsObject



138
139
140
141
# File 'lib/sequel/adapters/shared/postgres.rb', line 138

def force_standard_strings
  Sequel::Deprecation.deprecate("Sequel::Postgres.force_standard_strings", "Use the :force_standard_strings Database option instead")
  @force_standard_strings
end

.force_standard_strings=(v) ⇒ Object



142
143
144
145
# File 'lib/sequel/adapters/shared/postgres.rb', line 142

def force_standard_strings=(v)
  Sequel::Deprecation.deprecate("Sequel::Postgres.force_standard_strings=", "Use the :force_standard_strings Database option instead")
  @force_standard_strings = v
end

.mock_adapter_setup(db) ⇒ Object



114
115
116
117
118
119
120
# File 'lib/sequel/adapters/shared/postgres.rb', line 114

def self.mock_adapter_setup(db)
  db.instance_eval do
    @server_version = 90500
    initialize_postgres_adapter
    extend(MockAdapterDatabaseMethods)
  end
end

.sequel_pg_version_supported?(version) ⇒ Boolean

Whether the given sequel_pg version integer is supported.

Returns:

  • (Boolean)


37
38
39
# File 'lib/sequel/adapters/postgres.rb', line 37

def self.sequel_pg_version_supported?(version)
  version >= 10617
end

.use_iso_date_formatObject



45
46
47
48
# File 'lib/sequel/adapters/postgres.rb', line 45

def use_iso_date_format
  Sequel::Deprecation.deprecate("Sequel::Postgres.use_iso_date_format", "Use the :use_iso_date_format Database option instead")
  @use_iso_date_format
end

.use_iso_date_format=(v) ⇒ Object



49
50
51
52
# File 'lib/sequel/adapters/postgres.rb', line 49

def use_iso_date_format=(v)
  Sequel::Deprecation.deprecate("Sequel::Postgres.use_iso_date_format=", "Use the :use_iso_date_format Database option instead")
  @use_iso_date_format = v
end