firebird_adapter 1.0.2 → 1.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a48c9a2cd3d59a28cfc048e324f24a8df62015cb
4
- data.tar.gz: 26d5b223e8a9031290bfa05c907188f9cf2a2d9d
2
+ SHA256:
3
+ metadata.gz: a58a1cfffe5d2db00db303b202c951edd8a9e7a69ce5f517f5f4f82a69ad750a
4
+ data.tar.gz: 2305b01bac0fc96270e04a40670cb856a09611f61d6f2926b71fedc885587708
5
5
  SHA512:
6
- metadata.gz: 222a13f9ebab9064b42f168717f4edf8dac04234d69430665df3c9c38954beaf0a53a0a74aa9486152011885b68fc1c81154a657fca1bfa62ac86a578451adc9
7
- data.tar.gz: aa0803f76fe32ee201c7a2d874c1400b8789e65f7dc992e31949d8a3b64fb7d6d354c1be3bd31f4833a6440467b2682f7f8257d4a41d42c630b9bea5f12afad9
6
+ metadata.gz: e9ebbe4323c35e43abe2d5340094a7ea239a21445a257a687f8a45e68538e5d7caa4f94600db1e95161d6cb7d2cf3cbb858580b2bca3761b8e9ab3e6ef2dc2d6
7
+ data.tar.gz: 6e9bd26350107d4c1f181254f46af87905fa57ae86f1db6ab9b85dcaec6739468c8b16419405c337434cd6045ae73072914bd15222f27d164653b0790da64648
@@ -1,6 +1,8 @@
1
1
  module ActiveRecord::ConnectionHandling
2
2
  def firebird_connection(config)
3
- config = config.symbolize_keys.dup.reverse_merge(downcase_names: true, port: 3050, encoding: 'Windows-1252')
3
+ require 'active_record/extensions'
4
+
5
+ config = config.symbolize_keys.dup.reverse_merge(downcase_names: true, port: 3050, encoding: ActiveRecord::ConnectionAdapters::FirebirdAdapter::DEFAULT_ENCODING)
4
6
 
5
7
  if config[:host]
6
8
  config[:database] = "#{config[:host]}/#{config[:port]}:#{config[:database]}"
@@ -9,7 +9,10 @@ module ActiveRecord::ConnectionAdapters::Firebird::DatabaseStatements
9
9
  end
10
10
 
11
11
  def exec_query(sql, name = 'SQL', binds = [], prepare: false)
12
- type_casted_binds = type_casted_binds(binds)
12
+ type_casted_binds = type_casted_binds(binds).map do |value|
13
+ encoding = ActiveRecord::Base.connection_config[:encoding] || ActiveRecord::ConnectionAdapters::FirebirdAdapter::DEFAULT_ENCODING
14
+ value.encode(encoding) rescue value
15
+ end
13
16
 
14
17
  log(sql, name, binds, type_casted_binds) do
15
18
  ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
@@ -1,7 +1,6 @@
1
1
  require 'fb'
2
2
 
3
3
  require 'active_record/connection_adapters/firebird/connection'
4
- require 'active_record/connection_adapters/firebird/calculations'
5
4
  require 'active_record/connection_adapters/firebird/database_limits'
6
5
  require 'active_record/connection_adapters/firebird/database_statements'
7
6
  require 'active_record/connection_adapters/firebird/schema_statements'
@@ -11,6 +10,7 @@ require 'arel/visitors/firebird'
11
10
  class ActiveRecord::ConnectionAdapters::FirebirdAdapter < ActiveRecord::ConnectionAdapters::AbstractAdapter
12
11
 
13
12
  ADAPTER_NAME = "Firebird".freeze
13
+ DEFAULT_ENCODING = "Windows-1252".freeze
14
14
 
15
15
  include ActiveRecord::ConnectionAdapters::Firebird::DatabaseLimits
16
16
  include ActiveRecord::ConnectionAdapters::Firebird::DatabaseStatements
@@ -0,0 +1,24 @@
1
+ ActiveRecord::Calculations.module_eval do
2
+ def count(column_name = nil)
3
+ return super() if block_given?
4
+ calculate(:count, column_name || 1)
5
+ end
6
+ end
7
+
8
+ ActiveRecord::FinderMethods.module_eval do
9
+ def second
10
+ order(primary_key).limit(2).offset(2).to_a.first
11
+ end
12
+
13
+ def third
14
+ order(primary_key).limit(3).offset(3).to_a.first
15
+ end
16
+
17
+ def fourth
18
+ order(primary_key).limit(4).offset(4).to_a.first
19
+ end
20
+
21
+ def fifth
22
+ order(primary_key).limit(5).offset(5).to_a.first
23
+ end
24
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firebird_adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fábio Rodrigues
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-30 00:00:00.000000000 Z
11
+ date: 2019-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -115,12 +115,12 @@ executables: []
115
115
  extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
- - lib/active_record/connection_adapters/firebird/calculations.rb
119
118
  - lib/active_record/connection_adapters/firebird/connection.rb
120
119
  - lib/active_record/connection_adapters/firebird/database_limits.rb
121
120
  - lib/active_record/connection_adapters/firebird/database_statements.rb
122
121
  - lib/active_record/connection_adapters/firebird/schema_statements.rb
123
122
  - lib/active_record/connection_adapters/firebird_adapter.rb
123
+ - lib/active_record/extensions.rb
124
124
  - lib/arel/visitors/firebird.rb
125
125
  homepage: https://github.com/FabioMR/firebird_adapter
126
126
  licenses:
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  version: '0'
143
143
  requirements: []
144
144
  rubyforge_project:
145
- rubygems_version: 2.5.2.3
145
+ rubygems_version: 2.7.7
146
146
  signing_key:
147
147
  specification_version: 4
148
148
  summary: ActiveRecord Firebird Adapter for Rails 5.
@@ -1,6 +0,0 @@
1
- ActiveRecord::Calculations.module_eval do
2
- def count(column_name = nil)
3
- return super() if block_given?
4
- calculate(:count, column_name || 1)
5
- end
6
- end