Module | Sequel::Postgres::PGArray::DatabaseMethods |
In: |
lib/sequel/extensions/pg_array.rb
|
ESCAPE_RE | = | /("|\\)/.freeze |
ESCAPE_REPLACEMENT | = | '\\\\\1'.freeze |
Reset the conversion procs when extending the Database object, so it will pick up the array convertors. This is only done for the native postgres adapter.
# File lib/sequel/extensions/pg_array.rb, line 103 103: def self.extended(db) 104: db.reset_conversion_procs if db.respond_to?(:reset_conversion_procs) 105: end
Handle arrays in bound variables
# File lib/sequel/extensions/pg_array.rb, line 108 108: def bound_variable_arg(arg, conn) 109: case arg 110: when PGArray 111: bound_variable_array(arg.to_a) 112: when Array 113: bound_variable_array(arg) 114: else 115: super 116: end 117: end
Make the column type detection deal with string and numeric array types.
# File lib/sequel/extensions/pg_array.rb, line 120 120: def schema_column_type(db_type) 121: case db_type 122: when /\A(character( varying)?|text).*\[\]\z/io 123: :string_array 124: when /\A(integer|bigint|smallint)\[\]\z/io 125: :integer_array 126: when /\A(real|double precision)\[\]\z/io 127: :float_array 128: when /\Anumeric.*\[\]\z/io 129: :decimal_array 130: else 131: super 132: end 133: end