module ActiveRecord::ConnectionAdapters::RedshiftAdapter::Quoting
Public Instance Methods
escape_bytea(value)
click to toggle source
Escapes binary strings for bytea input to the database.
# File lib/active_record/connection_adapters/redshift/quoting.rb, line 6 def escape_bytea(value) PGconn.escape_bytea(value) if value end
quote_table_name(name)
click to toggle source
Checks the following cases:
-
table_name
-
“table.name”
-
schema_name.table_name
-
schema_name.“table.name”
-
“schema.name”.table_name
-
“schema.name”.“table.name”
# File lib/active_record/connection_adapters/redshift/quoting.rb, line 136 def quote_table_name(name) schema, name_part = extract_pg_identifier_from_name(name.to_s) unless name_part quote_column_name(schema) else table_name, name_part = extract_pg_identifier_from_name(name_part) "#{quote_column_name(schema)}.#{quote_column_name(table_name)}" end end
quote_table_name_for_assignment(table, attr)
click to toggle source
# File lib/active_record/connection_adapters/redshift/quoting.rb, line 147 def quote_table_name_for_assignment(table, attr) quote_column_name(attr) end
type_cast(value, column, array_member = false)
click to toggle source
Calls superclass method
# File lib/active_record/connection_adapters/redshift/quoting.rb, line 84 def type_cast(value, column, array_member = false) return super(value, column) unless column case value when Range return super(value, column) unless /range$/ =~ column.sql_type RedshiftColumn.range_to_string(value) when NilClass if column.array && array_member 'NULL' elsif column.array value else super(value, column) end when Array case column.sql_type when 'point' then RedshiftColumn.point_to_string(value) else return super(value, column) unless column.array RedshiftColumn.array_to_string(value, column, self) end when String return super(value, column) unless 'bytea' == column.sql_type { :value => value, :format => 1 } when Hash case column.sql_type when 'hstore' then RedshiftColumn.hstore_to_string(value) when 'json' then RedshiftColumn.json_to_string(value) else super(value, column) end when IPAddr return super(value, column) unless ['inet','cidr'].include? column.sql_type RedshiftColumn.cidr_to_string(value) else super(value, column) end end
unescape_bytea(value)
click to toggle source
Unescapes bytea output from a database to the binary string it represents. NOTE: This is NOT an inverse of escape_bytea
! This is only to be used on escaped binary output from database drive.
# File lib/active_record/connection_adapters/redshift/quoting.rb, line 13 def unescape_bytea(value) PGconn.unescape_bytea(value) if value end