activerecord-cubrid2-adapter 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e8634b1c39dd11d4694db73f13bf36b5f94a3a976f9d326dbffc5ce8e9145c2
4
- data.tar.gz: aad71acada082d9f3ddd1d7e339d4db8d6d6a7644824705daebed134d5c0f104
3
+ metadata.gz: '083943f215dc84e878a3d8d5d79c8b1a25703c1380ca2798c6e767205fcc792d'
4
+ data.tar.gz: 975804dda34c9ed0cc36ed5d37076ba0485cc0051b0fd08a9dbaa5079864d127
5
5
  SHA512:
6
- metadata.gz: ec45cc833218ea9b5193fecbeb27a3aacb85795a7a4a5495fb53ec7f73f8ebeb71a4589e55625222c5c69fe5d9684a964b86d9081c0353fe88e4581d5713f095
7
- data.tar.gz: 96882f548af718500348c060af3ab9563f04a504af3414304965e109abd7ab7896e442c815a7166c169298ae71eb62872bbb4d7f7e27d12a4267d26e572aca59
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.5
1
+ 0.1.0
@@ -199,6 +199,8 @@ module ActiveRecord
199
199
  materialize_transactions
200
200
 
201
201
  stmt = nil
202
+
203
+ # pp "######### #{sql}"
202
204
  log(sql, name) do
203
205
  ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
204
206
  stmt = @connection.query(sql)
@@ -239,19 +241,32 @@ module ActiveRecord
239
241
 
240
242
  # SCHEMA STATEMENTS ========================================
241
243
 
242
- # Drops the database: not supported now
243
- def recreate_database(_name, _options = {})
244
- 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)
245
248
  end
246
249
 
247
- # Create a new Cubrid database: not supported now
248
- def create_database(_name, _options = {})
249
- 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}"
250
263
  end
251
264
 
252
- # Drops a Cubrid database: not supported now
253
- def drop_database(_name) # :nodoc:
254
- 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}"
255
270
  end
256
271
 
257
272
  def current_database
@@ -462,18 +477,30 @@ module ActiveRecord
462
477
  prikeys
463
478
  end
464
479
 
465
- def default_uniqueness_comparison(attribute, value, klass) # :nodoc:
466
- 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)
467
483
 
468
- if column.collation && !column.case_sensitive? && !value.nil?
469
- ActiveSupport::Deprecation.warn(<<~MSG.squish)
470
- Uniqueness validator will no longer enforce case sensitive comparison in Rails 6.1.
471
- To continue case sensitive comparison on the :#{attribute.name} attribute in #{klass} model,
472
- pass `case_sensitive: true` option explicitly to the uniqueness validator.
473
- MSG
474
- attribute.eq(Arel::Nodes::Bin.new(value))
475
- else
476
- 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
477
504
  end
478
505
  end
479
506
 
@@ -38,8 +38,7 @@ module ActiveRecord
38
38
  sql << quote_column_name(o.name)
39
39
  # sql << "USING #{o.using}" if o.using
40
40
  sql << "ON #{quote_table_name(o.table)}" if create
41
- sql << "(#{quoted_columns(o)})"
42
-
41
+ sql << "(" + o.columns.map { |c| quote_column_name(c) }.join(', ') +")"
43
42
  add_sql_comment!(sql.join(' '), o.comment)
44
43
  end
45
44
 
@@ -95,7 +94,6 @@ module ActiveRecord
95
94
  index_name, index_type, index_columns, _, _, index_using, comment =
96
95
  @conn.add_index_options(table_name, column_name, **options)
97
96
  end
98
-
99
97
  add_sql_comment!(+"#{index_type} INDEX #{quote_column_name(index_name)} (#{index_columns})", comment)
100
98
  end
101
99
  end
@@ -55,7 +55,7 @@ module ActiveRecord
55
55
  indexes.map do |index|
56
56
  options = index.pop
57
57
 
58
- if expressions = options.delete(:expressions)
58
+ if (expressions = options.delete(:expressions))
59
59
  orders = options.delete(:orders)
60
60
  lengths = options.delete(:lengths)
61
61
 
@@ -101,13 +101,13 @@ module ActiveRecord
101
101
  def type_to_sql(type, limit: nil,
102
102
  precision: nil, scale: nil,
103
103
  size: limit_to_size(limit, type),
104
- unsigned: nil, **)
104
+ unsigned: nil, **options)
105
105
 
106
106
  case type.to_s
107
107
  when 'integer'
108
108
  integer_to_sql(limit)
109
109
  when 'serial'
110
- integer_to_sql(8) #bigint
110
+ integer_to_sql(8) # bigint
111
111
  when 'float', 'real', 'double', 'double precision'
112
112
  float_to_sql(limit)
113
113
  when 'text', 'string', 'varchar', 'char varing'
@@ -118,6 +118,8 @@ module ActiveRecord
118
118
  type_with_size_to_sql('blob', size)
119
119
  when 'clob'
120
120
  type_with_size_to_sql('clob', size)
121
+ when 'boolean'
122
+ type_with_size_to_sql('boolean', size)
121
123
  when 'nchar', 'nchar varing'
122
124
  raise 'Not supported from cubrid 9.0'
123
125
  else
@@ -235,6 +237,8 @@ module ActiveRecord
235
237
  'blob'
236
238
  when 'clob'
237
239
  'clob'
240
+ when 'boolean'
241
+ 'smallint'
238
242
  end
239
243
  end
240
244
 
@@ -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.5
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