activerecord-cubrid2-adapter 0.0.5 → 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 +4 -4
- data/README.md +2 -0
- data/VERSION +1 -1
- data/lib/active_record/connection_adapters/abstract_cubrid2_adapter.rb +47 -20
- data/lib/active_record/connection_adapters/cubrid2/schema_creation.rb +1 -3
- data/lib/active_record/connection_adapters/cubrid2/schema_statements.rb +7 -3
- data/lib/active_record/connection_adapters/cubrid2_adapter.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '083943f215dc84e878a3d8d5d79c8b1a25703c1380ca2798c6e767205fcc792d'
|
4
|
+
data.tar.gz: 975804dda34c9ed0cc36ed5d37076ba0485cc0051b0fd08a9dbaa5079864d127
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
+
[](https://badge.fury.io/rb/activerecord-cubrid2-adapter)
|
5
|
+
|
4
6
|
DESCRIPTION
|
5
7
|
-----------
|
6
8
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
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
|
-
#
|
243
|
-
def recreate_database(
|
244
|
-
|
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
|
248
|
-
|
249
|
-
|
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
|
253
|
-
|
254
|
-
|
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
|
-
|
466
|
-
|
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
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
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 << "(
|
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
|
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-
|
11
|
+
date: 2023-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|