activerecord-fb-adapter 0.8.4 → 0.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -597,16 +597,14 @@ module ActiveRecord
597
597
  # +binds+ as the bind substitutes. +name+ is logged along with
598
598
  # the executed +sql+ statement.
599
599
  def exec_query(sql, name = 'SQL', binds = [])
600
- if binds.empty?
601
- translate(sql) do |sql, args|
602
- log(expand(sql, args), name) do
603
- @connection.execute(sql, *args)
604
- end
600
+ translate(sql) do |sql, args|
601
+ unless binds.empty?
602
+ args = binds.map { |col, val| type_cast(val, col) } + args
605
603
  end
606
- else
607
- log(sql, name, binds) do
608
- args = binds.map { |col, val| type_cast(val, col) }
609
- @connection.execute(sql, *args)
604
+ log(expand(sql, args), name) do
605
+ fields, rows = @connection.execute(sql, *args) { |cursor| [cursor.fields, cursor.fetchall] }
606
+ cols = fields.map { |f| f.name }
607
+ ActiveRecord::Result.new(cols, rows)
610
608
  end
611
609
  end
612
610
  end
@@ -834,7 +832,13 @@ module ActiveRecord
834
832
  def add_column(table_name, column_name, type, options = {})
835
833
  add_column_sql = "ALTER TABLE #{quote_table_name(table_name)} ADD #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}"
836
834
  add_column_options!(add_column_sql, options)
837
- execute(add_column_sql)
835
+ begin
836
+ execute(add_column_sql)
837
+ rescue
838
+ raise unless non_existent_domain_error?
839
+ create_boolean_domain
840
+ execute(add_column_sql)
841
+ end
838
842
  if options[:position]
839
843
  # position is 1-based but add 1 to skip id column
840
844
  alter_position_sql = "ALTER TABLE #{quote_table_name(table_name)} ALTER COLUMN #{quote_column_name(column_name)} POSITION #{options[:position] + 1}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-fb-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 0.8.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-23 00:00:00.000000000 Z
12
+ date: 2014-02-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fb