Module: Torque::PostgreSQL::Adapter::Quoting

Included in:
Torque::PostgreSQL::Adapter
Defined in:
lib/torque/postgresql/adapter/quoting.rb

Constant Summary collapse

Name =
ActiveRecord::ConnectionAdapters::PostgreSQL::Name

Instance Method Summary collapse

Instance Method Details

#quote_default_expression(value, column) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/torque/postgresql/adapter/quoting.rb', line 22

def quote_default_expression(value, column)
  if value.class <= Array
    quote(value) + '::' + column.sql_type
  else
    super
  end
end

#quote_type_name(string, schema = nil) ⇒ Object

Quotes type names for use in SQL queries.



11
12
13
14
15
16
17
18
19
20
# File 'lib/torque/postgresql/adapter/quoting.rb', line 11

def quote_type_name(string, schema = nil)
  name_schema, table = string.to_s.scan(/[^".\s]+|"[^"]*"/)
  if table.nil?
    table = name_schema
    name_schema = nil
  end

  schema = schema || name_schema || 'public'
  Name.new(schema, table).quoted
end