activerecord-cubrid2-adapter 0.0.1 → 0.0.2

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: c06a871f89134bc5f13e2905a30968756ade6e68f72d7c227e5b186e65d05cd3
4
- data.tar.gz: c20757cde7ba8620d30f8a6f5803695a1492f1690470a6bc0f0c13b21a8af375
3
+ metadata.gz: fa9bb76dd730abb53dfc4a0dd0eed73aae65807102e0785f0f745e251b62a09f
4
+ data.tar.gz: 2584cfda25294f6534eebe581f37d6c87ef3fd3cafb08bb7bda5029ecf86d110
5
5
  SHA512:
6
- metadata.gz: e47475a4c8728ac72673f88abc60ab53179d6397d97930bf475f0b1005e0fe956ebed46ad5c16a16800bb4689d99626e074ba2136e4bff9e88c5a517f3f79da2
7
- data.tar.gz: 92bb1744b6427c10c923db59486e26c1687df128a63af79d842add0a3eb94d478d4db3fa0de6f73603aa25af074e3d517e1200d5d42af4b0696bed5e5c386759
6
+ metadata.gz: cbcec064f78631b61d99e198e99cd4c969a5933b4266b184597c9904daa2e5955ad45568a277a803f0a7285a9d4c08d972a64b7a66e67eac610951061d230bd3
7
+ data.tar.gz: 8f56f4cf68b369bf042bb0be92d818882b3764d283a63de6d50ec6ad524bab14b12ba67a5349e9c149ed73df9a2e6b08bf371a408efb75906f27f10edead70a8
data/README.md CHANGED
@@ -4,24 +4,25 @@ Cubrid database connector for ruby, and active_record, depends on 'cubrid' gem
4
4
  DESCRIPTION
5
5
  -----------
6
6
 
7
- Cubrid2 ActiveRecord adapter privides Cubrid database from Ruby on Rails applications. Now works with Ruby on Rails 6.0 and it is working with Cubrid database versions 9.x to higher.
8
-
9
- BUILD
10
- ------------
11
- ```ruby
12
- gem install rake-compiler
13
- rake build
14
- ```
7
+ Cubrid2 ActiveRecord adapter privides Cubrid database from Ruby on Rails applications. Now works with Ruby on Rails 6.0, 7.0 and it is working with Cubrid database versions 9.x to higher.
15
8
 
16
9
  INSTALLATION
17
10
  ------------
18
11
 
19
12
  ```ruby
20
13
  # Use cubrid as the database for Active Record
21
- gem 'cubrid' # cubrid interface gem, based on native CCI C interface
14
+ gem 'cubrid' # cubrid interface gem, based on native CCI C interface
15
+
16
+ # OR use local build
17
+ # git clone https://github.com/CUBRID/cubrid-ruby.git /opt/cubrid/cubrid-ruby
18
+ # cd /opt/cubrid/cubrid-ruby
19
+ # # goto directory and build cubrid-ruby
20
+
21
+ # gem 'cubrid', path: '/opt/cubrid/cubrid-ruby'
22
+
22
23
  gem 'activerecord-cubrid2-adapter'
23
24
  ```
24
- Currently Rails <6.0, >=7.0, Windows, JRuby is not tested.
25
+ Currently Rails Windows, JRuby is not tested.
25
26
 
26
27
  ### Without Rails and Bundler
27
28
 
@@ -31,9 +32,6 @@ If you want to use ActiveRecord and Cubrid2 adapter without Rails and Bundler th
31
32
  gem install activerecord-cubrid2-adapter
32
33
  ```
33
34
 
34
- USAGE
35
- -----
36
-
37
35
  ### Database connection
38
36
 
39
37
  In Rails application `config/database.yml` use 'cubrid2' as adapter name, e.g.
@@ -48,16 +46,27 @@ development:
48
46
  ```
49
47
 
50
48
  EXAMPLE
51
- -------------
49
+ -----
52
50
 
53
51
  Check test_activerecord.rb in the tests directory.
54
52
 
55
53
 
54
+ BUILDING GEM
55
+ -----
56
+
57
+ ```bash
58
+ gem install rake-compiler
59
+ rake build
60
+
61
+ # OR
62
+
63
+ gem build activerecord-cubrid2-adapter.gemspec
64
+ ```
65
+
56
66
  LINKS
57
67
  -----
58
68
 
59
- * Source code: https://github.com/damulhan/activerecord-cubrid2-adapter
60
- * Active Record – Object-relational mapping in Rails: https://github.com/rails/rails/tree/main/activerecord
61
- * Cubrid Ruby GEM: https://github.com/CUBRID/cubrid-ruby
69
+ * Active Record – Object-relational mapping in Rails: https://github.com/rails/rails/tree/main/activerecord
70
+ * Cubrid Ruby GEM: https://github.com/CUBRID/cubrid-ruby
62
71
  * Cubrid Homepage: https://www.cubrid.org
63
72
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -21,6 +21,6 @@ Gem::Specification.new do |spec|
21
21
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
22
  spec.require_paths = ['lib']
23
23
 
24
- spec.add_dependency 'activerecord', '~> 6.0'
24
+ spec.add_dependency 'activerecord', '>= 6.0'
25
25
  spec.add_dependency 'cubrid', '>= 10.0'
26
26
  end
@@ -144,7 +144,7 @@ module ActiveRecord
144
144
  end
145
145
 
146
146
  def index_algorithms
147
- { }
147
+ {}
148
148
  end
149
149
 
150
150
  # HELPER METHODS ===========================================
@@ -176,10 +176,10 @@ module ActiveRecord
176
176
 
177
177
  # CONNECTION MANAGEMENT ====================================
178
178
 
179
- def clear_cache! # :nodoc:
180
- reload_type_map
181
- super
182
- end
179
+ # def clear_cache! # :nodoc:
180
+ # reload_type_map
181
+ # super
182
+ # end
183
183
 
184
184
  #--
185
185
  # DATABASE STATEMENTS ======================================
@@ -351,11 +351,13 @@ module ActiveRecord
351
351
  end
352
352
 
353
353
  def change_column(table_name, column_name, type, options = {}) # :nodoc:
354
- execute("ALTER TABLE #{quote_table_name(table_name)} #{change_column_for_alter(table_name, column_name, type, **options)}")
354
+ execute("ALTER TABLE #{quote_table_name(table_name)} #{change_column_for_alter(table_name, column_name, type,
355
+ **options)}")
355
356
  end
356
357
 
357
358
  def rename_column(table_name, column_name, new_column_name) # :nodoc:
358
- execute("ALTER TABLE #{quote_table_name(table_name)} #{rename_column_for_alter(table_name, column_name, new_column_name)}")
359
+ execute("ALTER TABLE #{quote_table_name(table_name)} #{rename_column_for_alter(table_name, column_name,
360
+ new_column_name)}")
359
361
  rename_column_indexes(table_name, column_name, new_column_name)
360
362
  end
361
363
 
@@ -520,9 +522,9 @@ module ActiveRecord
520
522
  end
521
523
 
522
524
  def check_version # :nodoc:
523
- if database_version < '9.0'
524
- raise "Your version of Cubrid (#{database_version}) is too old. Active Record supports Cubrid >= 9.0."
525
- end
525
+ return unless database_version < '9.0'
526
+
527
+ raise "Your version of Cubrid (#{database_version}) is too old. Active Record supports Cubrid >= 9.0."
526
528
  end
527
529
 
528
530
  private
@@ -650,14 +652,15 @@ module ActiveRecord
650
652
  comment: column.comment
651
653
  }
652
654
 
653
- current_type = exec_query("SHOW COLUMNS FROM #{quote_table_name(table_name)} LIKE #{quote(column_name)}", "SCHEMA").first["Type"]
655
+ current_type = exec_query("SHOW COLUMNS FROM #{quote_table_name(table_name)} LIKE #{quote(column_name)}",
656
+ 'SCHEMA').first['Type']
654
657
  td = create_table_definition(table_name)
655
658
  cd = td.new_column_definition(new_column_name, current_type, **options)
656
659
  schema_creation.accept(ChangeColumnDefinition.new(cd, column.name))
657
660
  end
658
661
 
659
662
  def add_index_for_alter(table_name, column_name, **options)
660
- index, algorithm, _ = add_index_options(table_name, column_name, **options)
663
+ index, algorithm, = add_index_options(table_name, column_name, **options)
661
664
  algorithm = ", #{algorithm}" if algorithm
662
665
 
663
666
  "ADD #{schema_creation.accept(index)}#{algorithm}"
@@ -43,9 +43,8 @@ module ActiveRecord
43
43
 
44
44
  # make sure we carry over any changes to ActiveRecord::Base.default_timezone that have been
45
45
  # made since we established the connection
46
- @connection.query_options[:database_timezone] = ActiveRecord::Base.default_timezone
46
+ # @connection.query_options[:database_timezone] = ActiveRecord::Base.default_timezone
47
47
  # @connection.query_options[:database_timezone] = ActiveRecord.default_timezone
48
-
49
48
  super
50
49
  end
51
50
 
@@ -87,11 +86,11 @@ module ActiveRecord
87
86
  def _extract_rows_from_stmt__raw(stmt, as_hash: false)
88
87
  rows = []
89
88
  if as_hash
90
- while row = stmt.fetch_hash
89
+ while (row = stmt.fetch_hash)
91
90
  rows << row
92
91
  end
93
92
  else
94
- while row = stmt.fetch
93
+ while (row = stmt.fetch)
95
94
  rows << row
96
95
  end
97
96
  end
@@ -101,13 +100,13 @@ module ActiveRecord
101
100
  def _extract_rows_from_stmt__utf8(stmt, as_hash: false)
102
101
  rows = []
103
102
  if as_hash
104
- while row = stmt.fetch_hash
103
+ while (row = stmt.fetch_hash)
105
104
  rows << row.map do |x|
106
105
  [x[0], _as_utf8(x[1])]
107
106
  end.to_h
108
107
  end
109
108
  else
110
- while row = stmt.fetch
109
+ while (row = stmt.fetch)
111
110
  rows << row.map { |x| _as_utf8(x) }
112
111
  end
113
112
  end
data/lib/cubrid2.rb CHANGED
@@ -4,30 +4,30 @@ require 'bigdecimal'
4
4
  # Load libcubrid.dll before requiring cubrid/cubrid.so
5
5
  # This gives a chance to be flexible about the load path
6
6
  # Or to bomb out with a clear error message instead of a linker crash
7
- if RUBY_PLATFORM =~ /mswin|mingw/
8
- dll_path = if ENV['RUBY_CUBRID_LIBCUBRID_DLL']
9
- # If this environment variable is set, it overrides any other paths
10
- # The user is advised to use backslashes not forward slashes
11
- ENV['RUBY_CUBRID_LIBCUBRID_DLL']
12
- elsif File.exist?(File.expand_path('../vendor/libcubrid.dll', File.dirname(__FILE__)))
13
- # Use vendor/libcubrid.dll if it exists, convert slashes for Win32 LoadLibrary
14
- File.expand_path('../vendor/libcubrid.dll', File.dirname(__FILE__))
15
- # elsif defined?(RubyInstaller)
16
- # RubyInstaller-2.4+ native build doesn't need DLL preloading
17
- # else
18
- # This will use default / system library paths
19
- '../vendor/libcubrid.dll'
20
- end
7
+ # if RUBY_PLATFORM =~ /mswin|mingw/
8
+ # dll_path = if ENV['RUBY_CUBRID_LIBCUBRID_DLL']
9
+ # # If this environment variable is set, it overrides any other paths
10
+ # # The user is advised to use backslashes not forward slashes
11
+ # ENV['RUBY_CUBRID_LIBCUBRID_DLL']
12
+ # elsif File.exist?(File.expand_path('../vendor/libcubrid.dll', File.dirname(__FILE__)))
13
+ # # Use vendor/libcubrid.dll if it exists, convert slashes for Win32 LoadLibrary
14
+ # File.expand_path('../vendor/libcubrid.dll', File.dirname(__FILE__))
15
+ # # elsif defined?(RubyInstaller)
16
+ # # RubyInstaller-2.4+ native build doesn't need DLL preloading
17
+ # # else
18
+ # # This will use default / system library paths
19
+ # '../vendor/libcubrid.dll'
20
+ # end
21
21
 
22
- if dll_path
23
- require 'fiddle'
24
- kernel32 = Fiddle.dlopen 'kernel32'
25
- load_library = Fiddle::Function.new(
26
- kernel32['LoadLibraryW'], [Fiddle::TYPE_VOIDP], Fiddle::TYPE_INT
27
- )
28
- abort "Failed to load libcubrid.dll from #{dll_path}" if load_library.call(dll_path.encode('utf-16le')).zero?
29
- end
30
- end
22
+ # if dll_path
23
+ # require 'fiddle'
24
+ # kernel32 = Fiddle.dlopen 'kernel32'
25
+ # load_library = Fiddle::Function.new(
26
+ # kernel32['LoadLibraryW'], [Fiddle::TYPE_VOIDP], Fiddle::TYPE_INT
27
+ # )
28
+ # abort "Failed to load libcubrid.dll from #{dll_path}" if load_library.call(dll_path.encode('utf-16le')).zero?
29
+ # end
30
+ # end
31
31
 
32
32
  # load c extension
33
33
  gem 'cubrid', '>= 10.0'
data/tests/Gemfile CHANGED
@@ -1,10 +1,11 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # I cloned from original cubrid-ruby git repository to test
4
- # git clone https://github.com/CUBRID/cubrid-ruby.git
5
- gem 'cubrid', path: '/opt/cubrid/cubrid-ruby'
6
-
7
- gem 'activerecord', '~> 6.0'
8
- gem 'activerecord-cubrid2-adapter', path: '../'
3
+ gem 'activerecord', '~> 7.0'
9
4
  gem 'test-unit'
10
5
 
6
+ # gem 'cubrid'
7
+ gem 'cubrid', github: 'CUBRID/cubrid-ruby'
8
+ # gem 'cubrid', path: '/opt/cubrid/cubrid-ruby'
9
+
10
+ gem 'activerecord-cubrid2-adapter'
11
+ # gem 'activerecord-cubrid2-adapter', path: '..'
@@ -0,0 +1,61 @@
1
+ Loaded suite test_activerecord
2
+ Started
3
+ ### setup
4
+ -- activerecord-cubrid2-adapter version: 0.0.1
5
+ -- cubrid server version: 11.2.2.0705
6
+ -- charset: utf8
7
+ -- collation: utf8_bin
8
+ ### test_benchmark_insert
9
+ user system total real
10
+ 1th test
11
+ inserted id: 1
12
+ 2th test
13
+ inserted id: 2
14
+ 3th test
15
+ inserted id: 3
16
+ 4th test
17
+ inserted id: 4
18
+ 5th test
19
+ inserted id: 5
20
+ 6th test
21
+ inserted id: 6
22
+ 7th test
23
+ inserted id: 7
24
+ 8th test
25
+ inserted id: 8
26
+ 9th test
27
+ inserted id: 9
28
+ 10th test
29
+ inserted id: 10
30
+ 0.014243 0.002685 0.016928 ( 0.074481)
31
+ ### 10 rows inserted
32
+ ### teardown
33
+ .### setup
34
+ -- activerecord-cubrid2-adapter version: 0.0.1
35
+ -- cubrid server version: 11.2.2.0705
36
+ -- charset: utf8
37
+ -- collation: utf8_bin
38
+ ### test_insert
39
+ inserted id: 2
40
+ inserted id: 3
41
+ inserted id: 4
42
+ #<CubridTest:0x00007fdced0cdbf0
43
+ id: 3,
44
+ name: "test2",
45
+ body: "한글2",
46
+ created_at: 2023-01-20 11:19:29 UTC,
47
+ updated_at: 2023-01-20 11:19:29 UTC>
48
+ #<CubridTest:0x00007fdcf05901f8
49
+ id: 4,
50
+ name: "test3",
51
+ body: "中文3",
52
+ created_at: 2023-01-20 11:19:29 UTC,
53
+ updated_at: 2023-01-20 11:19:29 UTC>
54
+ ### teardown
55
+ .
56
+ Finished in 0.266551841 seconds.
57
+ -------------------------------------------------------------------------------
58
+ 2 tests, 5 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
59
+ 100% passed
60
+ -------------------------------------------------------------------------------
61
+ 7.50 tests/s, 18.76 assertions/s
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-cubrid2-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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-20 00:00:00.000000000 Z
11
+ date: 2023-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '6.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '6.0'
27
27
  - !ruby/object:Gem::Dependency
@@ -75,6 +75,7 @@ files:
75
75
  - lib/cubrid2/version.rb
76
76
  - tests/Gemfile
77
77
  - tests/test_activerecord.rb
78
+ - tests/test_activerecord_output_example.txt
78
79
  homepage: https://github.com/damulhan/activerecord-cubrid2-adapter
79
80
  licenses:
80
81
  - MIT
@@ -95,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
96
  - !ruby/object:Gem::Version
96
97
  version: '0'
97
98
  requirements: []
98
- rubygems_version: 3.3.7
99
+ rubygems_version: 3.1.4
99
100
  signing_key:
100
101
  specification_version: 4
101
102
  summary: ActiveRecord Cubrid Adapter.