activerecord-fb-adapter 0.7.5 → 0.7.8

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.
@@ -22,7 +22,7 @@ module Arel
22
22
  ].compact.join ' '
23
23
  end
24
24
 
25
- def visit_Arel_Nodes_UpdateStatement o
25
+ def visit_Arel_Nodes_UpdateStatement(o)
26
26
  [
27
27
  "UPDATE #{visit o.relation}",
28
28
  ("SET #{o.values.map { |value| visit(value) }.join ', '}" unless o.values.empty?),
@@ -81,13 +81,6 @@ module ActiveRecord
81
81
  @domain, @sub_type, @precision, @scale = domain, sub_type, precision, scale
82
82
  end
83
83
 
84
- # def type
85
- # if @type == :binary and @sub_type == 1
86
- # :text
87
- # else
88
- # @type
89
- # end
90
- # end
91
84
  def type
92
85
  if @domain =~ /BOOLEAN/
93
86
  :boolean
@@ -106,7 +99,12 @@ module ActiveRecord
106
99
  sql = "SELECT CAST(#{@default} AS #{column_def}) FROM RDB$DATABASE"
107
100
  connection = ActiveRecord::Base.connection
108
101
  if connection
109
- type_cast connection.select_one(sql)['cast']
102
+ value = connection.select_one(sql)['cast']
103
+ if value.acts_like?(:date) or value.acts_like?(:time)
104
+ nil
105
+ else
106
+ type_cast(value)
107
+ end
110
108
  else
111
109
  raise ConnectionNotEstablished, "No Firebird connections established."
112
110
  end
@@ -176,7 +174,7 @@ module ActiveRecord
176
174
  #
177
175
  # ...you can add the following line to your <tt>environment.rb</tt> file:
178
176
  #
179
- # ActiveRecord::ConnectionAdapters::FbAdapter.boolean_domain = { :true => 'T', :false => 'F' }
177
+ # ActiveRecord::ConnectionAdapters::FbAdapter.boolean_domain = { :true => 'T', :false => 'F', :name => 'BOOLEAN', :type => 'char' }
180
178
  #
181
179
  # === Column Name Case Semantics
182
180
  # Firebird and ActiveRecord have somewhat conflicting case semantics for
@@ -406,16 +404,22 @@ module ActiveRecord
406
404
  # end
407
405
 
408
406
  protected
409
- def translate(sql)
410
- sql.gsub!(/\bIN\s+\(NULL\)/i, 'IS NULL')
411
- sql.sub!(/\bWHERE\s.*$/im) do |m|
412
- m.gsub(/\s=\s*NULL\b/i, ' IS NULL')
407
+ if defined?(Encoding)
408
+ def decode(s)
409
+ Base64.decode64(s).force_encoding(@connection.encoding)
413
410
  end
411
+ else
412
+ def decode(s)
413
+ Base64.decode64(s)
414
+ end
415
+ end
416
+
417
+ def translate(sql)
414
418
  sql.gsub!(/\sIN\s+\([^\)]*\)/mi) do |m|
415
- m.gsub(/\(([^\)]*)\)/m) { |n| n.gsub(/\@(.*?)\@/m) { |n| "'#{quote_string(Base64.decode64(n[1..-1]))}'" } }
419
+ m.gsub(/\(([^\)]*)\)/m) { |n| n.gsub(/\@(.*?)\@/m) { |n| "'#{quote_string(decode(n[1..-1]))}'" } }
416
420
  end
417
421
  args = []
418
- sql.gsub!(/\@(.*?)\@/m) { |m| args << Base64.decode64(m[1..-1]); '?' }
422
+ sql.gsub!(/\@(.*?)\@/m) { |m| args << decode(m[1..-1]); '?' }
419
423
  yield(sql, args) if block_given?
420
424
  end
421
425
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-fb-adapter
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 5
10
- version: 0.7.5
9
+ - 8
10
+ version: 0.7.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brent Rowland
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-01-28 00:00:00 -08:00
18
+ date: 2013-08-01 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency