activerecord-tidb-adapter 6.1.2 → 7.0.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: f7a83c6f47ef9ff4341b013e4940eb694d3e12eb51c5965c0ceb1ab04e00f6e6
4
- data.tar.gz: 14eab9c135c9c948fde48803e7e630fe6b570e080207bb6adf41b669aeebd7bf
3
+ metadata.gz: 77b7efd6ea4bc98b6a72a6fb761aaab270881143f79eb362369b38e6cfa8965e
4
+ data.tar.gz: 878ca587a425ae2dd5fbe5bd2da03518b0dc7501c1b99a8c2f92c03fa39b1e19
5
5
  SHA512:
6
- metadata.gz: 5c3d8267b1985a86b3b1c9665d66a6c701f6da6eac9dd937bad83493c430c7abb1c38dc773370144ed8ebbe76bb6d1651615eaaf86ebe0f188ac5a04e8cb294f
7
- data.tar.gz: ef90da031efbe077422fcb3f19acf9abb73129fce6b6ab2c02ff103e496a5812db761e470731c9574b56af35a43edcfa12762da137d629b04cd251a98f3496d8
6
+ metadata.gz: c8a5a80313df31083a7c0d54f8e2145ca148293f1844c644bb7530f77e1e73d736e9c79ae5c1d3b89d3b94fae5024bc565ec80a1cb659508e105a2894734c660
7
+ data.tar.gz: d6004fba604462b1358166c96ed905161dfb40c38285d9050ee0c42497ec6ad32bc897640b628cdc35a7c977d36688905d78a92d84308f7ce9bb76d8cf9171eb
@@ -4,4 +4,4 @@ env:
4
4
 
5
5
  steps:
6
6
  - command: "testing.sh"
7
- label: "Run TiDB ActiveRecord Adapter testing 6-1-stable"
7
+ label: "Run TiDB ActiveRecord Adapter testing"
@@ -1,15 +1,17 @@
1
- name: activerecord-tidb-adapter 6-1
1
+ name: activerecord-tidb-adapter main
2
2
 
3
3
  on:
4
4
  push:
5
5
  branches:
6
- - 6-1-stable
6
+ - main
7
+ - 7-0-stable
7
8
  paths-ignore:
8
9
  - 'README*.md'
9
10
  - 'docs/**'
10
11
  pull_request:
11
12
  branches:
12
- - 6-1-stable
13
+ - main
14
+ - 7-0-stable
13
15
  paths-ignore:
14
16
  - 'README*.md'
15
17
  - 'docs/**'
@@ -29,7 +31,8 @@ jobs:
29
31
  - uses: ruby/setup-ruby@v1
30
32
  with:
31
33
  ruby-version: 2.7
32
- bundler-cache: true
34
+ bundler-cache: false
35
+ - run: bundle install
33
36
  - run: sleep 30 && MYSQL_USER=root MYSQL_HOST=127.0.0.1 MYSQL_PORT=4000 tidb=1 ARCONN=tidb bundle exec rake db:tidb:build
34
37
  - run: sleep 10 && MYSQL_USER=root MYSQL_HOST=127.0.0.1 MYSQL_PORT=4000 tidb=1 ARCONN=tidb bundle exec rake test:tidb
35
38
 
@@ -47,7 +50,8 @@ jobs:
47
50
  - uses: ruby/setup-ruby@v1
48
51
  with:
49
52
  ruby-version: 2.7
50
- bundler-cache: true
53
+ bundler-cache: false
54
+ - run: bundle install
51
55
  - run: sleep 30 && MYSQL_USER=root MYSQL_HOST=127.0.0.1 MYSQL_PORT=4000 tidb=1 ARCONN=tidb bundle exec rake db:tidb:build
52
56
  - run: mysql --host 127.0.0.1 --database activerecord_unittest --port 4000 -u root -e 'set @@global.tidb_enable_change_column_type = 1'
53
57
  - run: mysql --host 127.0.0.1 --database activerecord_unittest2 --port 4000 -u root -e 'set @@global.tidb_enable_change_column_type = 1'
@@ -67,7 +71,8 @@ jobs:
67
71
  - uses: ruby/setup-ruby@v1
68
72
  with:
69
73
  ruby-version: 2.7
70
- bundler-cache: true
74
+ bundler-cache: false
75
+ - run: bundle install
71
76
  - run: sleep 30 && MYSQL_USER=root MYSQL_HOST=127.0.0.1 MYSQL_PORT=4000 tidb=1 ARCONN=tidb bundle exec rake db:tidb:build
72
77
  - run: sleep 10 && MYSQL_USER=root MYSQL_HOST=127.0.0.1 MYSQL_PORT=4000 tidb=1 ARCONN=tidb bundle exec rake test:tidb
73
78
 
@@ -85,6 +90,7 @@ jobs:
85
90
  - uses: ruby/setup-ruby@v1
86
91
  with:
87
92
  ruby-version: 2.7
88
- bundler-cache: true
93
+ bundler-cache: false
94
+ - run: bundle install
89
95
  - run: sleep 30 && MYSQL_USER=root MYSQL_HOST=127.0.0.1 MYSQL_PORT=4000 tidb=1 ARCONN=tidb bundle exec rake db:tidb:build
90
96
  - run: sleep 10 && MYSQL_USER=root MYSQL_HOST=127.0.0.1 MYSQL_PORT=4000 tidb=1 ARCONN=tidb bundle exec rake test:tidb
data/Gemfile CHANGED
@@ -14,10 +14,12 @@ gem 'pry'
14
14
 
15
15
  gem 'rubocop', '~> 1.18'
16
16
 
17
- gem 'rails', git: 'https://github.com/pingcap/rails.git', branch: '6-1-stable'
17
+ gem 'rails', git: 'https://github.com/pingcap/rails.git', branch: '7-0-stable'
18
18
 
19
19
  gem 'byebug', '~> 11.1'
20
20
 
21
21
  gem 'sqlite3', '~> 1.4'
22
22
 
23
23
  gem 'pg', '~> 1.2'
24
+
25
+ gem "benchmark-ips", "~> 2.9"
data/Gemfile.lock CHANGED
@@ -1,126 +1,150 @@
1
1
  GIT
2
2
  remote: https://github.com/pingcap/rails.git
3
- revision: e2a3d3fb2ee24c709b9f32221fbcb66cfda5acfc
4
- branch: 6-1-stable
3
+ revision: 8e88c0ecd838d642c542e8246a0b7c6e9df9c806
4
+ branch: 7-0-stable
5
5
  specs:
6
- actioncable (6.1.4)
7
- actionpack (= 6.1.4)
8
- activesupport (= 6.1.4)
6
+ actioncable (7.0.2.3)
7
+ actionpack (= 7.0.2.3)
8
+ activesupport (= 7.0.2.3)
9
9
  nio4r (~> 2.0)
10
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)
11
+ actionmailbox (7.0.2.3)
12
+ actionpack (= 7.0.2.3)
13
+ activejob (= 7.0.2.3)
14
+ activerecord (= 7.0.2.3)
15
+ activestorage (= 7.0.2.3)
16
+ activesupport (= 7.0.2.3)
17
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)
18
+ net-imap
19
+ net-pop
20
+ net-smtp
21
+ actionmailer (7.0.2.3)
22
+ actionpack (= 7.0.2.3)
23
+ actionview (= 7.0.2.3)
24
+ activejob (= 7.0.2.3)
25
+ activesupport (= 7.0.2.3)
23
26
  mail (~> 2.5, >= 2.5.4)
27
+ net-imap
28
+ net-pop
29
+ net-smtp
24
30
  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)
31
+ actionpack (7.0.2.3)
32
+ actionview (= 7.0.2.3)
33
+ activesupport (= 7.0.2.3)
34
+ rack (~> 2.0, >= 2.2.0)
29
35
  rack-test (>= 0.6.3)
30
36
  rails-dom-testing (~> 2.0)
31
37
  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)
38
+ actiontext (7.0.2.3)
39
+ actionpack (= 7.0.2.3)
40
+ activerecord (= 7.0.2.3)
41
+ activestorage (= 7.0.2.3)
42
+ activesupport (= 7.0.2.3)
43
+ globalid (>= 0.6.0)
37
44
  nokogiri (>= 1.8.5)
38
- actionview (6.1.4)
39
- activesupport (= 6.1.4)
45
+ actionview (7.0.2.3)
46
+ activesupport (= 7.0.2.3)
40
47
  builder (~> 3.1)
41
48
  erubi (~> 1.4)
42
49
  rails-dom-testing (~> 2.0)
43
50
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
44
- activejob (6.1.4)
45
- activesupport (= 6.1.4)
51
+ activejob (7.0.2.3)
52
+ activesupport (= 7.0.2.3)
46
53
  globalid (>= 0.3.6)
47
- activemodel (6.1.4)
48
- activesupport (= 6.1.4)
49
- activerecord (6.1.4)
50
- activemodel (= 6.1.4)
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)
54
+ activemodel (7.0.2.3)
55
+ activesupport (= 7.0.2.3)
56
+ activerecord (7.0.2.3)
57
+ activemodel (= 7.0.2.3)
58
+ activesupport (= 7.0.2.3)
59
+ activestorage (7.0.2.3)
60
+ actionpack (= 7.0.2.3)
61
+ activejob (= 7.0.2.3)
62
+ activerecord (= 7.0.2.3)
63
+ activesupport (= 7.0.2.3)
64
+ marcel (~> 1.0)
58
65
  mini_mime (>= 1.1.0)
59
- activesupport (6.1.4)
66
+ activesupport (7.0.2.3)
60
67
  concurrent-ruby (~> 1.0, >= 1.0.2)
61
68
  i18n (>= 1.6, < 2)
62
69
  minitest (>= 5.1)
63
70
  tzinfo (~> 2.0)
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)
71
+ rails (7.0.2.3)
72
+ actioncable (= 7.0.2.3)
73
+ actionmailbox (= 7.0.2.3)
74
+ actionmailer (= 7.0.2.3)
75
+ actionpack (= 7.0.2.3)
76
+ actiontext (= 7.0.2.3)
77
+ actionview (= 7.0.2.3)
78
+ activejob (= 7.0.2.3)
79
+ activemodel (= 7.0.2.3)
80
+ activerecord (= 7.0.2.3)
81
+ activestorage (= 7.0.2.3)
82
+ activesupport (= 7.0.2.3)
77
83
  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)
84
+ railties (= 7.0.2.3)
85
+ railties (7.0.2.3)
86
+ actionpack (= 7.0.2.3)
87
+ activesupport (= 7.0.2.3)
83
88
  method_source
84
- rake (>= 0.13)
89
+ rake (>= 12.2)
85
90
  thor (~> 1.0)
91
+ zeitwerk (~> 2.5)
86
92
 
87
93
  PATH
88
94
  remote: .
89
95
  specs:
90
- activerecord-tidb-adapter (6.1.2)
91
- activerecord (~> 6.1)
96
+ activerecord-tidb-adapter (7.0.0)
97
+ activerecord (~> 7.0.1)
92
98
  mysql2
93
99
 
94
100
  GEM
95
101
  remote: https://rubygems.org/
96
102
  specs:
97
103
  ast (2.4.2)
104
+ benchmark-ips (2.9.1)
98
105
  builder (3.2.4)
99
106
  byebug (11.1.3)
100
107
  coderay (1.1.3)
101
- concurrent-ruby (1.1.9)
108
+ concurrent-ruby (1.1.10)
102
109
  crass (1.0.6)
110
+ digest (3.1.0)
103
111
  erubi (1.10.0)
104
- globalid (0.5.2)
112
+ globalid (1.0.0)
105
113
  activesupport (>= 5.0)
106
- i18n (1.8.10)
114
+ i18n (1.10.0)
107
115
  concurrent-ruby (~> 1.0)
108
- loofah (2.12.0)
116
+ io-wait (0.2.1)
117
+ loofah (2.15.0)
109
118
  crass (~> 1.0.2)
110
119
  nokogiri (>= 1.5.9)
111
120
  mail (2.7.1)
112
121
  mini_mime (>= 0.1.1)
113
- marcel (1.0.1)
122
+ marcel (1.0.2)
114
123
  method_source (1.0.0)
115
- mini_mime (1.1.0)
124
+ mini_mime (1.1.2)
116
125
  minitest (5.14.4)
117
126
  minitest-excludes (2.0.1)
118
127
  minitest (~> 5.0)
119
128
  mysql2 (0.5.3)
129
+ net-imap (0.2.3)
130
+ digest
131
+ net-protocol
132
+ strscan
133
+ net-pop (0.1.1)
134
+ digest
135
+ net-protocol
136
+ timeout
137
+ net-protocol (0.1.2)
138
+ io-wait
139
+ timeout
140
+ net-smtp (0.3.1)
141
+ digest
142
+ net-protocol
143
+ timeout
120
144
  nio4r (2.5.8)
121
- nokogiri (1.12.3-x86_64-darwin)
145
+ nokogiri (1.13.3-x86_64-darwin)
122
146
  racc (~> 1.4)
123
- nokogiri (1.12.3-x86_64-linux)
147
+ nokogiri (1.13.3-x86_64-linux)
124
148
  racc (~> 1.4)
125
149
  parallel (1.20.1)
126
150
  parser (3.0.2.0)
@@ -129,14 +153,14 @@ GEM
129
153
  pry (0.14.1)
130
154
  coderay (~> 1.1)
131
155
  method_source (~> 1.0)
132
- racc (1.5.2)
156
+ racc (1.6.0)
133
157
  rack (2.2.3)
134
158
  rack-test (1.1.0)
135
159
  rack (>= 1.0, < 3)
136
160
  rails-dom-testing (2.0.3)
137
161
  activesupport (>= 4.2.0)
138
162
  nokogiri (>= 1.6)
139
- rails-html-sanitizer (1.4.1)
163
+ rails-html-sanitizer (1.4.2)
140
164
  loofah (~> 2.3)
141
165
  rainbow (3.0.0)
142
166
  rake (13.0.6)
@@ -154,29 +178,27 @@ GEM
154
178
  rubocop-ast (1.10.0)
155
179
  parser (>= 3.0.1.1)
156
180
  ruby-progressbar (1.11.0)
157
- sprockets (4.0.2)
158
- concurrent-ruby (~> 1.0)
159
- rack (> 1, < 3)
160
- sprockets-rails (3.2.2)
161
- actionpack (>= 4.0)
162
- activesupport (>= 4.0)
163
- sprockets (>= 3.0.0)
164
181
  sqlite3 (1.4.2)
165
- thor (1.1.0)
182
+ strscan (3.0.1)
183
+ thor (1.2.1)
184
+ timeout (0.2.0)
166
185
  tzinfo (2.0.4)
167
186
  concurrent-ruby (~> 1.0)
168
187
  unicode-display_width (2.0.0)
169
188
  websocket-driver (0.7.5)
170
189
  websocket-extensions (>= 0.1.0)
171
190
  websocket-extensions (0.1.5)
172
- zeitwerk (2.4.2)
191
+ zeitwerk (2.5.4)
173
192
 
174
193
  PLATFORMS
175
194
  x86_64-darwin-18
195
+ x86_64-darwin-20
196
+ x86_64-darwin-21
176
197
  x86_64-linux
177
198
 
178
199
  DEPENDENCIES
179
200
  activerecord-tidb-adapter!
201
+ benchmark-ips (~> 2.9)
180
202
  byebug (~> 11.1)
181
203
  minitest (~> 5.0)
182
204
  minitest-excludes (~> 2.0)
@@ -188,4 +210,4 @@ DEPENDENCIES
188
210
  sqlite3 (~> 1.4)
189
211
 
190
212
  BUNDLED WITH
191
- 2.2.25
213
+ 2.3.10
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # ActiveRecord TiDB Adapter
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/activerecord-tidb-adapter.svg)](https://badge.fury.io/rb/activerecord-tidb-adapter)
4
+ [![activerecord-tidb-adapter 7.0](https://github.com/pingcap/activerecord-tidb-adapter/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/pingcap/activerecord-tidb-adapter/actions/workflows/ci.yml)
5
+
3
6
  TiDB adapter for ActiveRecord 5.2, 6.1 and 7.0
4
7
  This is a lightweight extension of the mysql2 adapter that establishes compatibility with [TiDB](https://github.com/pingcap/tidb).
5
8
 
@@ -9,12 +12,12 @@ This is a lightweight extension of the mysql2 adapter that establishes compatibi
9
12
  Add this line to your application's Gemfile:
10
13
 
11
14
  ```ruby
12
- gem 'activerecord-tidb-adapter', "~> 6.1.0"
15
+ gem 'activerecord-tidb-adapter', '~> 6.1.0'
13
16
  ```
14
17
 
15
18
  If you're using Rails 5.2, use the 5.2.x versions of this gem.
16
19
 
17
- If you're using Rails 7.0, use the 7.0.x versions of this gem.
20
+ If you're using Rails 6.1, use the 6.1.x versions of this gem.
18
21
 
19
22
  And then execute:
20
23
 
@@ -73,24 +76,6 @@ class TestSeq < ActiveRecord::Migration[6.1]
73
76
  end
74
77
  ```
75
78
 
76
- Generated DDL
77
- ```sql
78
- mysql> show create table orders_seq\G;
79
- *************************** 1. row ***************************
80
- Sequence: orders_seq
81
- Create Sequence: CREATE SEQUENCE `orders_seq` start with 1024 minvalue 1 maxvalue 9223372036854775806 increment by 1 nocache nocycle ENGINE=InnoDB
82
-
83
- mysql> show create table orders\G;
84
- *************************** 1. row ***************************
85
- Table: orders
86
- Create Table: CREATE TABLE `orders` (
87
- `id` bigint(20) NOT NULL DEFAULT nextval(`activerecord_tidb_adapter_demo_development`.`orders_seq`),
88
- `name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
89
- PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */
90
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
91
-
92
- ```
93
-
94
79
  This gem also adds a few helpers to interact with `SEQUENCE`
95
80
 
96
81
  ```ruby
@@ -104,6 +89,41 @@ ActiveRecord::Base.lastval("numbers")
104
89
  ActiveRecord::Base.setval("numbers", 1234)
105
90
  ```
106
91
 
92
+ **[CTE](https://docs.pingcap.com/tidb/dev/sql-statement-with#with)**
93
+
94
+ ```bash
95
+ $ bundle add activerecord-cte
96
+
97
+ ```
98
+
99
+ ```ruby
100
+ require 'activerecord/cte'
101
+
102
+ Post
103
+ .with(posts_with_tags: "SELECT * FROM posts WHERE tags_count > 0")
104
+ .from("posts_with_tags AS posts")
105
+ # WITH posts_with_tags AS (
106
+ # SELECT * FROM posts WHERE (tags_count > 0)
107
+ # )
108
+ # SELECT * FROM posts_with_tags AS posts
109
+
110
+ Post
111
+ .with(posts_with_tags: "SELECT * FROM posts WHERE tags_count > 0")
112
+ .from("posts_with_tags AS posts")
113
+ .count
114
+
115
+ # WITH posts_with_tags AS (
116
+ # SELECT * FROM posts WHERE (tags_count > 0)
117
+ # )
118
+ # SELECT COUNT(*) FROM posts_with_tags AS posts
119
+
120
+ Post
121
+ .with(posts_with_tags: Post.where("tags_count > 0"))
122
+ .from("posts_with_tags AS posts")
123
+ .count
124
+
125
+ ```
126
+
107
127
 
108
128
  ## Setting up local TiDB server
109
129
 
@@ -118,6 +138,10 @@ Starting TiDB playground
118
138
  $ tiup playground nightly
119
139
  ```
120
140
 
141
+ ## Tutorials
142
+
143
+ * [Build a Rails App with TiDB and the ActiveRecord TiDB Adapter](https://gist.github.com/hooopo/83db933ab07a054f70e23da0ff945747)
144
+
121
145
  ## Development
122
146
 
123
147
  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.
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = 'Allows the use of TiDB as a backend for ActiveRecord and Rails apps.'
13
13
  spec.homepage = 'https://github.com/pingcap/activerecord-tidb-adapter'
14
14
  spec.license = 'Apache-2.0'
15
- spec.required_ruby_version = '>= 2.5.0'
15
+ spec.required_ruby_version = '>= 2.7.0'
16
16
 
17
17
  # spec.metadata["allowed_push_host"] = "TODO: Set to 'https://mygemserver.com'"
18
18
 
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
30
  spec.require_paths = ['lib']
31
31
 
32
- spec.add_dependency 'activerecord', '~> 6.1'
32
+ spec.add_dependency 'activerecord', '~> 7.0.1'
33
33
  spec.add_dependency 'mysql2'
34
34
 
35
35
  # Uncomment to register a new dependency of your gem
@@ -15,4 +15,11 @@ ActiveRecord::ConnectionAdapters::DatabaseStatements.class_eval do
15
15
  end
16
16
  end
17
17
  alias create insert
18
- end
18
+
19
+ def transaction_isolation_levels
20
+ {
21
+ read_committed: 'READ COMMITTED',
22
+ repeatable_read: 'REPEATABLE READ'
23
+ }
24
+ end
25
+ end
@@ -38,18 +38,22 @@ module ActiveRecord
38
38
  ADAPTER_NAME = 'Tidb'
39
39
 
40
40
  def supports_savepoints?
41
+ # https://github.com/pingcap/tidb/issues/6840 support is required
41
42
  false
42
43
  end
43
44
 
44
45
  def supports_foreign_keys?
46
+ # https://github.com/pingcap/tidb/issues/18209 support is required
45
47
  false
46
48
  end
47
49
 
48
50
  def supports_bulk_alter?
51
+ # https://github.com/pingcap/tidb/issues/14766 support is required
49
52
  false
50
53
  end
51
54
 
52
55
  def supports_advisory_locks?
56
+ # https://github.com/pingcap/tidb/issues/14994 support is required
53
57
  false
54
58
  end
55
59
 
@@ -62,25 +66,23 @@ module ActiveRecord
62
66
  end
63
67
 
64
68
  def supports_index_sort_order?
65
- # TODO: check TiDB version
66
- true
69
+ # https://github.com/pingcap/tidb/issues/2519 support is required
70
+ false
67
71
  end
68
72
 
69
73
  def supports_expression_index?
70
- false
74
+ sql = <<~SQL
75
+ SELECT VALUE
76
+ FROM INFORMATION_SCHEMA.CLUSTER_CONFIG
77
+ WHERE `KEY` = 'experimental.allow-expression-index' AND `TYPE` = 'tidb'
78
+ SQL
79
+ query_value(sql) == 'true'
71
80
  end
72
81
 
73
82
  def supports_common_table_expressions?
74
83
  tidb_version >= '5.1.0'
75
84
  end
76
85
 
77
- def transaction_isolation_levels
78
- {
79
- read_committed: 'READ COMMITTED',
80
- repeatable_read: 'REPEATABLE READ'
81
- }
82
- end
83
-
84
86
  def initialize(connection, logger, conn_params, config)
85
87
  super(connection, logger, conn_params, config)
86
88
 
@@ -108,6 +110,7 @@ module ActiveRecord
108
110
  default_function = nil
109
111
 
110
112
  if type_metadata.type == :datetime && /\ACURRENT_TIMESTAMP(?:\([0-6]?\))?\z/i.match?(default)
113
+ default = "#{default} ON UPDATE #{default}" if /on update CURRENT_TIMESTAMP/i.match?(field[:Extra])
111
114
  default_function = default
112
115
  default = nil
113
116
  elsif type_metadata.extra == 'DEFAULT_GENERATED'
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 = '6.1.2'
4
+ TIDB_ADAPTER_VERSION = '7.0.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: 6.1.2
4
+ version: 7.0.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-09-08 00:00:00.000000000 Z
11
+ date: 2022-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '6.1'
19
+ version: 7.0.1
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
- version: '6.1'
26
+ version: 7.0.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mysql2
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -87,7 +87,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - ">="
89
89
  - !ruby/object:Gem::Version
90
- version: 2.5.0
90
+ version: 2.7.0
91
91
  required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - ">="