activerecord-cubrid2-adapter 0.0.6 → 0.1.0

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
2
  SHA256:
3
- metadata.gz: fb5f0b9e757c88be9651a7fec3f108efbf54ad4c0bc7d6394c88a515691620f9
4
- data.tar.gz: ae0a80d45a7ad82610a9c571e7e888758b796ce915df58f6aae168b4ed4b3dcb
3
+ metadata.gz: '083943f215dc84e878a3d8d5d79c8b1a25703c1380ca2798c6e767205fcc792d'
4
+ data.tar.gz: 975804dda34c9ed0cc36ed5d37076ba0485cc0051b0fd08a9dbaa5079864d127
5
5
  SHA512:
6
- metadata.gz: c73b48aa18376691eb9d56f087e03e7b9d7943835fe2d405f37b946dec10e6b863a81c5698561be44da39fe5f989ab6f07ca3d7c4a41f6f76572e60d6033eae2
7
- data.tar.gz: f31316136f7f417d7eb9874f639b51a38acaa55164ee23f800437cc4ab54ab7cc2c8aeb4bbd32ac69ff54ab4733f671c74149932a0cdc41fa9b180aaa321751c
6
+ metadata.gz: 823ff2da41876111cb1cb3cce15171fcb9790536305658c7389e63f11447b7343f8f4dcd8aa771b804d927367be3b99361a5a1c4a2fc4dbb41388d39421c00a7
7
+ data.tar.gz: '08c0ae544747c7a8b2fae2ad44d07b64d8097c499113b3eff9baf77e78268783bd277c70fbf1767b7625d99f11f54710a847c7e209d1c6f5d2706ecb3157f53c'
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # activerecord-cubrid2-adapter
2
2
  Cubrid database connector for ruby, and active_record, depends on 'cubrid' gem
3
3
 
4
+ [![Gem Version](https://badge.fury.io/rb/activerecord-cubrid2-adapter.svg)](https://badge.fury.io/rb/activerecord-cubrid2-adapter)
5
+
4
6
  DESCRIPTION
5
7
  -----------
6
8
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.1.0
@@ -200,7 +200,7 @@ module ActiveRecord
200
200
 
201
201
  stmt = nil
202
202
 
203
- #pp "######### #{sql}"
203
+ # pp "######### #{sql}"
204
204
  log(sql, name) do
205
205
  ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
206
206
  stmt = @connection.query(sql)
@@ -241,19 +241,32 @@ module ActiveRecord
241
241
 
242
242
  # SCHEMA STATEMENTS ========================================
243
243
 
244
- # Drops the database: not supported now
245
- def recreate_database(_name, _options = {})
246
- raise 'In Cubrid create/drop database not supported'
244
+ # Recreate database
245
+ def recreate_database(name, options = {})
246
+ drop_database(name)
247
+ create_database(name, options)
247
248
  end
248
249
 
249
- # Create a new Cubrid database: not supported now
250
- def create_database(_name, _options = {})
251
- raise 'In Cubrid create/drop database not supported'
250
+ # Create a new Cubrid database
251
+ # TODO: not workign with rake db:create
252
+ def create_database(name, options = {})
253
+ options[:db_volume_size] ||= '20' # megabytes
254
+ options[:log_volume_size] ||= '20' # megabytes
255
+ options[:encoding] ||= 'en_US.utf8'
256
+
257
+ Kernel.exec 'cubrid createdb ' +
258
+ "--db-volume-size=#{options[:db_volume_size]}M " +
259
+ "--log-volume-size=#{options[:log_volume_size]}M #{name} " +
260
+ "#{options[:encoding]}"
261
+
262
+ Kernel.exec "cubrid service start #{name}"
252
263
  end
253
264
 
254
- # Drops a Cubrid database: not supported now
255
- def drop_database(_name) # :nodoc:
256
- raise 'In Cubrid create/drop database not supported'
265
+ # Drops a Cubrid database
266
+ # TODO: not workign with rake db:drop
267
+ def drop_database(name)
268
+ Kernel.exec "cubrid service stop #{name}"
269
+ Kernel.exec "cubrid deletedb #{name}"
257
270
  end
258
271
 
259
272
  def current_database
@@ -464,18 +477,30 @@ module ActiveRecord
464
477
  prikeys
465
478
  end
466
479
 
467
- def default_uniqueness_comparison(attribute, value, klass) # :nodoc:
468
- column = column_for_attribute(attribute)
480
+ if ActiveRecord.version.to_s < '6.1.3.1'
481
+ def default_uniqueness_comparison(attribute, value, klass = nil) # :nodoc:
482
+ column = column_for_attribute(attribute)
469
483
 
470
- if column.collation && !column.case_sensitive? && !value.nil?
471
- ActiveSupport::Deprecation.warn(<<~MSG.squish)
472
- Uniqueness validator will no longer enforce case sensitive comparison in Rails 6.1.
473
- To continue case sensitive comparison on the :#{attribute.name} attribute in #{klass} model,
474
- pass `case_sensitive: true` option explicitly to the uniqueness validator.
475
- MSG
476
- attribute.eq(Arel::Nodes::Bin.new(value))
477
- else
478
- super
484
+ if column.collation && !column.case_sensitive? && !value.nil?
485
+ ActiveSupport::Deprecation.warn(<<~MSG.squish)
486
+ Uniqueness validator will no longer enforce case sensitive comparison in Rails 6.1.
487
+ To continue case sensitive comparison on the :#{attribute.name} attribute in #{klass} model,
488
+ pass `case_sensitive: true` option explicitly to the uniqueness validator.
489
+ MSG
490
+ attribute.eq(Arel::Nodes::Bin.new(value))
491
+ else
492
+ super
493
+ end
494
+ end
495
+ else
496
+ def default_uniqueness_comparison(attribute, value) # :nodoc:
497
+ column = column_for_attribute(attribute)
498
+
499
+ if column.collation && !column.case_sensitive? && !value.nil?
500
+ attribute.eq(Arel::Nodes::Bin.new(value))
501
+ else
502
+ super
503
+ end
479
504
  end
480
505
  end
481
506
 
@@ -13,7 +13,7 @@ module ActiveRecord
13
13
  config = config.symbolize_keys
14
14
  config[:flags] ||= 0
15
15
 
16
- client = Cubrid2::Client.new(config)
16
+ client = ::Cubrid2::Client.new(config)
17
17
  ConnectionAdapters::Cubrid2Adapter.new(client, logger, nil, config)
18
18
  rescue Cubrid2::Error => e
19
19
  raise ActiveRecord::NoDatabaseError if e.error_number == ER_DATABASE_CONNECTION_ERROR
@@ -145,7 +145,7 @@ module ActiveRecord
145
145
  private
146
146
 
147
147
  def connect
148
- @connection = Cubrid2::Client.new(@config)
148
+ @connection = ::Cubrid2::Client.new(@config)
149
149
  configure_connection
150
150
  end
151
151
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-cubrid2-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eui-Taik Na
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-27 00:00:00.000000000 Z
11
+ date: 2023-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  requirements: []
105
- rubygems_version: 3.4.1
105
+ rubygems_version: 3.3.7
106
106
  signing_key:
107
107
  specification_version: 4
108
108
  summary: ActiveRecord Cubrid Adapter.