method
quote
v2.1.0 -
Show latest stable
- Class:
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
quote(value, column = nil)public
Quotes PostgreSQL-specific data types for SQL input.
# File activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 331
def quote(value, column = nil) #:nodoc:
if value.kind_of?(String) && column && column.type == :binary
"#{quoted_string_prefix}'#{column.class.string_to_binary(value)}'"
elsif value.kind_of?(String) && column && column.sql_type =~ /^xml$/
"xml '#{quote_string(value)}'"
elsif value.kind_of?(Numeric) && column && column.sql_type =~ /^money$/
# Not truly string input, so doesn't require (or allow) escape string syntax.
"'#{value.to_s}'"
elsif value.kind_of?(String) && column && column.sql_type =~ /^bit/
case value
when /^[01]*$/
"B'#{value}'" # Bit-string notation
when /^[0-9A-F]*$/i
"X'#{value}'" # Hexadecimal notation
end
else
super
end
end Related methods
- Instance methods
- active?
- adapter_name
- add_column
- add_order_by_for_association_limiting!
- begin_db_transaction
- change_column
- change_column_default
- change_column_null
- client_min_messages
- client_min_messages=
- columns
- commit_db_transaction
- create_database
- default_sequence_name
- disable_referential_integrity
- disconnect!
- distinct
- drop_database
- execute
- indexes
- insert
- native_database_types
- pk_and_sequence_for
- query
- quote
- quote_column_name
- quote_string
- quoted_date
- reconnect!
- recreate_database
- remove_index
- rename_column
- rename_table
- reset_pk_sequence!
- result_as_array
- rollback_db_transaction
- schema_search_path
- schema_search_path=
- select_rows
- supports_disable_referential_integrity?
- supports_migrations?
- supports_standard_conforming_strings?
- table_alias_length
- tables
- type_to_sql
- update_sql
- Class methods
- new
- Protected methods
-
postgresql_version - Private methods
-
column_definitions -
configure_connection -
connect -
last_insert_id -
select -
select_raw