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
Public Class
Public Instance
Classes and Modules
Constants
CONVERTED_EXCEPTIONS | = | [] |
Array of exceptions that need to be converted. JDBC uses NativeExceptions, the native adapter uses PGError. |
|
DASH_STR | = | '-'.freeze | ||
MINUS_INFINITY | = | -1.0/0.0 | ||
MINUS_INFINITY_STR | = | '-Infinity'.freeze | ||
NAN | = | 0.0/0.0 | ||
NAN_STR | = | 'NaN'.freeze | ||
PG_NAMED_TYPES | = | {} unless defined?(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_TYPES | = | {} unless defined?(PG_TYPES) |
Hash with integer keys and callable values for converting PostgreSQL types. |
|
PLUS_INFINITY | = | 1.0/0.0 | ||
PLUS_INFINITY_STR | = | 'Infinity'.freeze | ||
STRING_TYPES | = | [18, 19, 25, 1042, 1043] |
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). |
|
TRUE_STR | = | 't'.freeze | ||
TYPE_TRANSLATOR | = | tt = Class.new do def boolean(s) s == TRUE_STR end def integer(s) s.to_i end def float(s) case s when NAN_STR NAN when PLUS_INFINITY_STR PLUS_INFINITY when MINUS_INFINITY_STR MINUS_INFINITY else s.to_f end end def date(s) ::Date.new(*s.split(DASH_STR).map{|x| x.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 |
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 Instance methods
# File lib/sequel/adapters/postgres.rb, line 96 def bytea(s) ::Sequel::SQL::Blob.new(Adapter.unescape_bytea(s)) end