activerecord-tidb-adapter 0.2.0 → 0.3.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: 8ad173cdbfab54d867f0116350b372fc06224abb5c3166da8d59dcbe59125d5e
4
- data.tar.gz: 03a849590718d9d94f9d59730d51f001050c00ad09d54ba7dcd9470625627dd1
3
+ metadata.gz: 442a2dcd175987185739a1fad7a8ef8788d0b13b7263018795ac144a4c10ee03
4
+ data.tar.gz: e568154643ebebfc8a9dcfd506b18732d52dea1a19b6500b76e9103965fd2cff
5
5
  SHA512:
6
- metadata.gz: 86b8d677d14434d8db2c688caf99946bbc8357d729abcdea9c707330f792cd190cebdfd47b7e9305154ed41399fdaf0315b9f5d718217c922c92faecbcaf80d0
7
- data.tar.gz: 563c533e208b02539137b94f5b0e4f6939114dacec5a04524e31744bd8267ead0db261d4e04e02c997b3a2d9646959d56c095aa7be72974cbfa67b91f20a9d9c
6
+ metadata.gz: d01699afa9a6c147317b8b6fd5763bcbf63852bccaa4fe6dd5bac076405bfc02ff98ae177cd1eef39a8aac95493a4e7eac31896260bceb8b78d2c2b3976605c6
7
+ data.tar.gz: 932f70292fde728c25d21bf7180dbad488ca4b5d7630bfe669b70dbf1dee0165f24b311d284ed0ab8edd1b5ab1b688d28d29e7a1748c8a571101950568373a00
data/.gitignore CHANGED
@@ -6,3 +6,8 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ /sqlnet.log
10
+ /test/config.yml
11
+ /test/db/
12
+ /test/fixtures/*.sqlite*
13
+ /debug.log
data/Gemfile CHANGED
@@ -8,7 +8,16 @@ gemspec
8
8
  gem 'rake', '~> 13.0'
9
9
 
10
10
  gem 'minitest', '~> 5.0'
11
+ gem 'minitest-excludes', '~> 2.0'
11
12
 
12
13
  gem 'pry'
13
14
 
14
15
  gem 'rubocop', '~> 1.18'
16
+
17
+ gem 'rails', git: 'https://github.com/tidb-incubator/rails.git', branch: '6-1-stable'
18
+
19
+ gem 'byebug', '~> 11.1'
20
+
21
+ gem 'sqlite3', '~> 1.4'
22
+
23
+ gem 'pg', '~> 1.2'
data/Gemfile.lock CHANGED
@@ -1,38 +1,141 @@
1
- PATH
2
- remote: .
3
- specs:
4
- activerecord-tidb-adapter (0.2.0)
5
- activerecord (~> 6.1)
6
- mysql2
7
-
8
- GEM
9
- remote: https://rubygems.org/
1
+ GIT
2
+ remote: https://github.com/tidb-incubator/rails.git
3
+ revision: e377e0dc16e9841a048ec7eab2666c06155b6a0c
4
+ branch: 6-1-stable
10
5
  specs:
6
+ actioncable (6.1.4)
7
+ actionpack (= 6.1.4)
8
+ activesupport (= 6.1.4)
9
+ nio4r (~> 2.0)
10
+ websocket-driver (>= 0.6.1)
11
+ actionmailbox (6.1.4)
12
+ actionpack (= 6.1.4)
13
+ activejob (= 6.1.4)
14
+ activerecord (= 6.1.4)
15
+ activestorage (= 6.1.4)
16
+ activesupport (= 6.1.4)
17
+ mail (>= 2.7.1)
18
+ actionmailer (6.1.4)
19
+ actionpack (= 6.1.4)
20
+ actionview (= 6.1.4)
21
+ activejob (= 6.1.4)
22
+ activesupport (= 6.1.4)
23
+ mail (~> 2.5, >= 2.5.4)
24
+ rails-dom-testing (~> 2.0)
25
+ actionpack (6.1.4)
26
+ actionview (= 6.1.4)
27
+ activesupport (= 6.1.4)
28
+ rack (~> 2.0, >= 2.0.9)
29
+ rack-test (>= 0.6.3)
30
+ rails-dom-testing (~> 2.0)
31
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
32
+ actiontext (6.1.4)
33
+ actionpack (= 6.1.4)
34
+ activerecord (= 6.1.4)
35
+ activestorage (= 6.1.4)
36
+ activesupport (= 6.1.4)
37
+ nokogiri (>= 1.8.5)
38
+ actionview (6.1.4)
39
+ activesupport (= 6.1.4)
40
+ builder (~> 3.1)
41
+ erubi (~> 1.4)
42
+ rails-dom-testing (~> 2.0)
43
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
44
+ activejob (6.1.4)
45
+ activesupport (= 6.1.4)
46
+ globalid (>= 0.3.6)
11
47
  activemodel (6.1.4)
12
48
  activesupport (= 6.1.4)
13
49
  activerecord (6.1.4)
14
50
  activemodel (= 6.1.4)
15
51
  activesupport (= 6.1.4)
52
+ activestorage (6.1.4)
53
+ actionpack (= 6.1.4)
54
+ activejob (= 6.1.4)
55
+ activerecord (= 6.1.4)
56
+ activesupport (= 6.1.4)
57
+ marcel (~> 1.0.0)
58
+ mini_mime (>= 1.1.0)
16
59
  activesupport (6.1.4)
17
60
  concurrent-ruby (~> 1.0, >= 1.0.2)
18
61
  i18n (>= 1.6, < 2)
19
62
  minitest (>= 5.1)
20
63
  tzinfo (~> 2.0)
21
64
  zeitwerk (~> 2.3)
65
+ rails (6.1.4)
66
+ actioncable (= 6.1.4)
67
+ actionmailbox (= 6.1.4)
68
+ actionmailer (= 6.1.4)
69
+ actionpack (= 6.1.4)
70
+ actiontext (= 6.1.4)
71
+ actionview (= 6.1.4)
72
+ activejob (= 6.1.4)
73
+ activemodel (= 6.1.4)
74
+ activerecord (= 6.1.4)
75
+ activestorage (= 6.1.4)
76
+ activesupport (= 6.1.4)
77
+ bundler (>= 1.15.0)
78
+ railties (= 6.1.4)
79
+ sprockets-rails (>= 2.0.0)
80
+ railties (6.1.4)
81
+ actionpack (= 6.1.4)
82
+ activesupport (= 6.1.4)
83
+ method_source
84
+ rake (>= 0.13)
85
+ thor (~> 1.0)
86
+
87
+ PATH
88
+ remote: .
89
+ specs:
90
+ activerecord-tidb-adapter (0.3.0)
91
+ activerecord (~> 6.1)
92
+ mysql2
93
+
94
+ GEM
95
+ remote: https://rubygems.org/
96
+ specs:
22
97
  ast (2.4.2)
98
+ builder (3.2.4)
99
+ byebug (11.1.3)
23
100
  coderay (1.1.3)
24
101
  concurrent-ruby (1.1.9)
102
+ crass (1.0.6)
103
+ erubi (1.10.0)
104
+ globalid (0.5.2)
105
+ activesupport (>= 5.0)
25
106
  i18n (1.8.10)
26
107
  concurrent-ruby (~> 1.0)
108
+ loofah (2.11.0)
109
+ crass (~> 1.0.2)
110
+ nokogiri (>= 1.5.9)
111
+ mail (2.7.1)
112
+ mini_mime (>= 0.1.1)
113
+ marcel (1.0.1)
27
114
  method_source (1.0.0)
115
+ mini_mime (1.1.0)
28
116
  minitest (5.14.4)
117
+ minitest-excludes (2.0.1)
118
+ minitest (~> 5.0)
29
119
  mysql2 (0.5.3)
120
+ nio4r (2.5.8)
121
+ nokogiri (1.12.3-x86_64-linux)
122
+ racc (~> 1.4)
30
123
  parallel (1.20.1)
31
124
  parser (3.0.2.0)
32
125
  ast (~> 2.4.1)
126
+ pg (1.2.3)
33
127
  pry (0.14.1)
34
128
  coderay (~> 1.1)
35
129
  method_source (~> 1.0)
130
+ racc (1.5.2)
131
+ rack (2.2.3)
132
+ rack-test (1.1.0)
133
+ rack (>= 1.0, < 3)
134
+ rails-dom-testing (2.0.3)
135
+ activesupport (>= 4.2.0)
136
+ nokogiri (>= 1.6)
137
+ rails-html-sanitizer (1.3.0)
138
+ loofah (~> 2.3)
36
139
  rainbow (3.0.0)
37
140
  rake (13.0.6)
38
141
  regexp_parser (2.1.1)
@@ -49,9 +152,21 @@ GEM
49
152
  rubocop-ast (1.8.0)
50
153
  parser (>= 3.0.1.1)
51
154
  ruby-progressbar (1.11.0)
155
+ sprockets (4.0.2)
156
+ concurrent-ruby (~> 1.0)
157
+ rack (> 1, < 3)
158
+ sprockets-rails (3.2.2)
159
+ actionpack (>= 4.0)
160
+ activesupport (>= 4.0)
161
+ sprockets (>= 3.0.0)
162
+ sqlite3 (1.4.2)
163
+ thor (1.1.0)
52
164
  tzinfo (2.0.4)
53
165
  concurrent-ruby (~> 1.0)
54
166
  unicode-display_width (2.0.0)
167
+ websocket-driver (0.7.5)
168
+ websocket-extensions (>= 0.1.0)
169
+ websocket-extensions (0.1.5)
55
170
  zeitwerk (2.4.2)
56
171
 
57
172
  PLATFORMS
@@ -60,10 +175,15 @@ PLATFORMS
60
175
 
61
176
  DEPENDENCIES
62
177
  activerecord-tidb-adapter!
178
+ byebug (~> 11.1)
63
179
  minitest (~> 5.0)
180
+ minitest-excludes (~> 2.0)
181
+ pg (~> 1.2)
64
182
  pry
183
+ rails!
65
184
  rake (~> 13.0)
66
185
  rubocop (~> 1.18)
186
+ sqlite3 (~> 1.4)
67
187
 
68
188
  BUNDLED WITH
69
189
  2.2.25
data/README.md CHANGED
@@ -21,7 +21,7 @@ Or install it yourself as:
21
21
 
22
22
  ## Usage
23
23
 
24
- database.yml
24
+ config/database.yml
25
25
 
26
26
  ```yml
27
27
  default: &default
@@ -44,16 +44,57 @@ development:
44
44
 
45
45
  * demo repo with rails 6.1.4: https://github.com/hooopo/activerecord-tidb-adapter-demo
46
46
 
47
+ ## Setting up local TiDB server
48
+
49
+ Install [tiup](https://github.com/pingcap/tiup)
50
+
51
+ ```shell
52
+ $ curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
53
+ ```
54
+ Starting TiDB playground
55
+
56
+ ```shell
57
+ $ tiup playground nightly
58
+ ```
59
+
47
60
  ## Development
48
61
 
49
62
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
50
63
 
51
64
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
52
65
 
66
+ ## Testing
67
+
68
+ install gems
69
+
70
+ ```
71
+ bundle install
72
+ ```
73
+
74
+ start tidb server
75
+
76
+ ```
77
+ tiup playground nightly
78
+ ```
79
+
80
+ create database for testing
81
+
82
+ ```
83
+ MYSQL_USER=root MYSQL_HOST=127.0.0.1 MYSQL_PORT=4000 tidb=1 ARCONN=tidb bundle exec rake db:tidb:rebuild
84
+
85
+ ```
86
+
87
+ run tidb adapter tests
88
+
89
+ ```
90
+ MYSQL_USER=root MYSQL_HOST=127.0.0.1 MYSQL_PORT=4000 tidb=1 ARCONN=tidb bundle exec rake test:idb
91
+
92
+ ```
93
+
53
94
  ## Contributing
54
95
 
55
96
  Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/activerecord-tidb-adapter.
56
97
 
57
98
  ## License
58
99
 
59
- Apache 2.0
100
+ Apache 2.0
data/Rakefile CHANGED
@@ -2,11 +2,56 @@
2
2
 
3
3
  require 'bundler/gem_tasks'
4
4
  require 'rake/testtask'
5
+ require 'pry'
5
6
 
6
- Rake::TestTask.new(:test) do |t|
7
- t.libs << 'test'
8
- t.libs << 'lib'
9
- t.test_files = FileList['test/**/*_test.rb']
7
+ require_relative 'test/support/paths_tidb'
8
+ require_relative 'test/support/rake_helpers'
9
+ require_relative 'test/support/config'
10
+
11
+ task test: ['test:tidb']
12
+ task default: [:test]
13
+
14
+ namespace :test do
15
+ Rake::TestTask.new('tidb') do |t|
16
+ t.libs = ARTest::TiDB.test_load_paths
17
+ t.test_files = test_files
18
+ t.warning = !!ENV['WARNING']
19
+ t.verbose = false
20
+ end
21
+
22
+ task 'tidb:env' do
23
+ ENV['ARCONN'] = 'tidb'
24
+ ENV['tidb'] = '1'
25
+ end
26
+ end
27
+
28
+ task 'test:tidb' => 'test:tidb:env'
29
+
30
+ namespace :db do
31
+ namespace :tidb do
32
+ connection_arguments = lambda do |connection_name|
33
+ config = ARTest.config['connections']['tidb'][connection_name]
34
+ ["--user=#{config['username']}", "--password=#{config['password']}", "--port=#{config['port']}",
35
+ ("--host=#{config['host']}" if config['host'])].join(' ')
36
+ end
37
+
38
+ desc 'Build the TiDB test databases'
39
+ task :build do
40
+ config = ARTest.config['connections']['tidb']
41
+ `mysql #{connection_arguments['arunit']} -e "create DATABASE #{config['arunit']['database']} DEFAULT CHARACTER SET utf8mb4 COLLATE #{config['arunit']['collation']}"`
42
+ `mysql #{connection_arguments['arunit2']} -e "create DATABASE #{config['arunit2']['database']} DEFAULT CHARACTER SET utf8mb4 COLLATE #{config['arunit2']['collation']}"`
43
+ end
44
+
45
+ desc 'Drop the TiDB test databases'
46
+ task :drop do
47
+ config = ARTest.config['connections']['tidb']
48
+ `mysqladmin #{connection_arguments['arunit']} -f drop #{config['arunit']['database']}`
49
+ `mysqladmin #{connection_arguments['arunit2']} -f drop #{config['arunit2']['database']}`
50
+ end
51
+
52
+ desc 'Rebuild the TiDB test databases'
53
+ task rebuild: %i[drop build]
54
+ end
10
55
  end
11
56
 
12
- task default: :test
57
+ task build_mysql_databases: 'db:mysql:build'
data/config.toml ADDED
@@ -0,0 +1 @@
1
+ new_collations_enabled_on_first_bootstrap = true
@@ -67,11 +67,7 @@ module ActiveRecord
67
67
  end
68
68
 
69
69
  def supports_common_table_expressions?
70
- if tidb_version >= '5.1.0'
71
- true
72
- else
73
- false
74
- end
70
+ tidb_version >= '5.1.0'
75
71
  end
76
72
 
77
73
  def transaction_isolation_levels
@@ -85,7 +81,7 @@ module ActiveRecord
85
81
  super(connection, logger, conn_params, config)
86
82
 
87
83
  tidb_version_string = query_value('select version()')
88
- @tidb_version = tidb_version_string[/TiDB-v([0-9\.]+)/, 1]
84
+ @tidb_version = tidb_version_string[/TiDB-v([0-9.]+)/, 1]
89
85
  end
90
86
 
91
87
  def tidb_version_string
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRecord
4
- TIDB_ADAPTER_VERSION = '0.2.0'
4
+ TIDB_ADAPTER_VERSION = '0.3.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-tidb-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hooopo Wang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-08 00:00:00.000000000 Z
11
+ date: 2021-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -45,7 +45,6 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - ".github/workflows/main.yml"
49
48
  - ".gitignore"
50
49
  - Gemfile
51
50
  - Gemfile.lock
@@ -55,6 +54,7 @@ files:
55
54
  - activerecord-tidb-adapter.gemspec
56
55
  - bin/console
57
56
  - bin/setup
57
+ - config.toml
58
58
  - lib/active_record/connection_adapters/tidb/database_tasks.rb
59
59
  - lib/active_record/connection_adapters/tidb/setup.rb
60
60
  - lib/active_record/connection_adapters/tidb/type.rb
@@ -1,16 +0,0 @@
1
- name: Ruby
2
-
3
- on: [push,pull_request]
4
-
5
- jobs:
6
- build:
7
- runs-on: ubuntu-latest
8
- steps:
9
- - uses: actions/checkout@v2
10
- - name: Set up Ruby
11
- uses: ruby/setup-ruby@v1
12
- with:
13
- ruby-version: 2.7.0
14
- bundler-cache: true
15
- - name: Run the default task
16
- run: bundle exec rake