activerecord-tidb-adapter 5.2.2 → 6.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/Gemfile +1 -5
- data/Gemfile.lock +73 -58
- data/README.md +1 -1
- data/activerecord-tidb-adapter.gemspec +1 -1
- data/lib/active_record/connection_adapters/tidb_adapter.rb +46 -23
- data/lib/version.rb +1 -1
- metadata +4 -11
- data/.buildkite/hooks/pre-command +0 -10
- data/.buildkite/pipeline.yml +0 -7
- data/.github/entrypoint.sh +0 -16
- data/.github/workflows/ci.yml +0 -35
- data/lib/active_record/connection_adapters/tidb/database_statements.rb +0 -19
- data/lib/active_record/connection_adapters/tidb/schema_statements.rb +0 -28
- data/testing.sh +0 -14
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5f82e1eb06fb93971e146fafade1c45e2e3c5909e3968f32a719c9581efb55f3
|
|
4
|
+
data.tar.gz: 5a0bc0100489a41230115924cbff3f52e1ef2206441724116135ed01ccdd28da
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0b059eabd253b3e7e0ead32528ac380d874dd9ab42ff942ec86ff3ddec86257b00aa5aea3c44912f95d3c0c8ba2dc7e8ba0a33abff668f6100f929fc2ed45f61
|
|
7
|
+
data.tar.gz: 216b0b9917670ca40cd30d3c243493e88aaf2279d946b68eaa927b0a65d78226e075279f12c8839f32a4d9be8b3edb7c348ba2038cd25bfa2845dc62aa9d4944
|
data/Gemfile
CHANGED
|
@@ -14,14 +14,10 @@ gem 'pry'
|
|
|
14
14
|
|
|
15
15
|
gem 'rubocop', '~> 1.18'
|
|
16
16
|
|
|
17
|
-
gem 'rails', git: 'https://github.com/pingcap/rails.git', branch: '
|
|
17
|
+
gem 'rails', git: 'https://github.com/pingcap/rails.git', branch: '6-1-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 "mocha", "~> 1.13"
|
|
26
|
-
|
|
27
|
-
gem "bcrypt", "~> 3.1"
|
data/Gemfile.lock
CHANGED
|
@@ -1,82 +1,100 @@
|
|
|
1
1
|
GIT
|
|
2
2
|
remote: https://github.com/pingcap/rails.git
|
|
3
|
-
revision:
|
|
4
|
-
branch:
|
|
3
|
+
revision: e2a3d3fb2ee24c709b9f32221fbcb66cfda5acfc
|
|
4
|
+
branch: 6-1-stable
|
|
5
5
|
specs:
|
|
6
|
-
actioncable (
|
|
7
|
-
actionpack (=
|
|
6
|
+
actioncable (6.1.4)
|
|
7
|
+
actionpack (= 6.1.4)
|
|
8
|
+
activesupport (= 6.1.4)
|
|
8
9
|
nio4r (~> 2.0)
|
|
9
10
|
websocket-driver (>= 0.6.1)
|
|
10
|
-
|
|
11
|
-
actionpack (=
|
|
12
|
-
|
|
13
|
-
|
|
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)
|
|
14
23
|
mail (~> 2.5, >= 2.5.4)
|
|
15
24
|
rails-dom-testing (~> 2.0)
|
|
16
|
-
actionpack (
|
|
17
|
-
actionview (=
|
|
18
|
-
activesupport (=
|
|
19
|
-
rack (~> 2.0, >= 2.0.
|
|
25
|
+
actionpack (6.1.4)
|
|
26
|
+
actionview (= 6.1.4)
|
|
27
|
+
activesupport (= 6.1.4)
|
|
28
|
+
rack (~> 2.0, >= 2.0.9)
|
|
20
29
|
rack-test (>= 0.6.3)
|
|
21
30
|
rails-dom-testing (~> 2.0)
|
|
22
|
-
rails-html-sanitizer (~> 1.0, >= 1.0
|
|
23
|
-
|
|
24
|
-
|
|
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)
|
|
25
40
|
builder (~> 3.1)
|
|
26
41
|
erubi (~> 1.4)
|
|
27
42
|
rails-dom-testing (~> 2.0)
|
|
28
|
-
rails-html-sanitizer (~> 1.
|
|
29
|
-
activejob (
|
|
30
|
-
activesupport (=
|
|
43
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
|
44
|
+
activejob (6.1.4)
|
|
45
|
+
activesupport (= 6.1.4)
|
|
31
46
|
globalid (>= 0.3.6)
|
|
32
|
-
activemodel (
|
|
33
|
-
activesupport (=
|
|
34
|
-
activerecord (
|
|
35
|
-
activemodel (=
|
|
36
|
-
activesupport (=
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
activerecord (=
|
|
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)
|
|
41
57
|
marcel (~> 1.0.0)
|
|
42
|
-
|
|
58
|
+
mini_mime (>= 1.1.0)
|
|
59
|
+
activesupport (6.1.4)
|
|
43
60
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
44
|
-
i18n (>=
|
|
45
|
-
minitest (
|
|
46
|
-
tzinfo (~>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
i18n (>= 1.6, < 2)
|
|
62
|
+
minitest (>= 5.1)
|
|
63
|
+
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)
|
|
77
|
+
bundler (>= 1.15.0)
|
|
78
|
+
railties (= 6.1.4)
|
|
59
79
|
sprockets-rails (>= 2.0.0)
|
|
60
|
-
railties (
|
|
61
|
-
actionpack (=
|
|
62
|
-
activesupport (=
|
|
80
|
+
railties (6.1.4)
|
|
81
|
+
actionpack (= 6.1.4)
|
|
82
|
+
activesupport (= 6.1.4)
|
|
63
83
|
method_source
|
|
64
|
-
rake (>= 0.
|
|
65
|
-
thor (
|
|
84
|
+
rake (>= 0.13)
|
|
85
|
+
thor (~> 1.0)
|
|
66
86
|
|
|
67
87
|
PATH
|
|
68
88
|
remote: .
|
|
69
89
|
specs:
|
|
70
|
-
activerecord-tidb-adapter (
|
|
71
|
-
activerecord (~>
|
|
90
|
+
activerecord-tidb-adapter (6.1.0)
|
|
91
|
+
activerecord (~> 6.1)
|
|
72
92
|
mysql2
|
|
73
93
|
|
|
74
94
|
GEM
|
|
75
95
|
remote: https://rubygems.org/
|
|
76
96
|
specs:
|
|
77
|
-
arel (9.0.0)
|
|
78
97
|
ast (2.4.2)
|
|
79
|
-
bcrypt (3.1.16)
|
|
80
98
|
builder (3.2.4)
|
|
81
99
|
byebug (11.1.3)
|
|
82
100
|
coderay (1.1.3)
|
|
@@ -98,7 +116,6 @@ GEM
|
|
|
98
116
|
minitest (5.14.4)
|
|
99
117
|
minitest-excludes (2.0.1)
|
|
100
118
|
minitest (~> 5.0)
|
|
101
|
-
mocha (1.13.0)
|
|
102
119
|
mysql2 (0.5.3)
|
|
103
120
|
nio4r (2.5.8)
|
|
104
121
|
nokogiri (1.12.3-x86_64-darwin)
|
|
@@ -146,13 +163,13 @@ GEM
|
|
|
146
163
|
sprockets (>= 3.0.0)
|
|
147
164
|
sqlite3 (1.4.2)
|
|
148
165
|
thor (1.1.0)
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
thread_safe (~> 0.1)
|
|
166
|
+
tzinfo (2.0.4)
|
|
167
|
+
concurrent-ruby (~> 1.0)
|
|
152
168
|
unicode-display_width (2.0.0)
|
|
153
169
|
websocket-driver (0.7.5)
|
|
154
170
|
websocket-extensions (>= 0.1.0)
|
|
155
171
|
websocket-extensions (0.1.5)
|
|
172
|
+
zeitwerk (2.4.2)
|
|
156
173
|
|
|
157
174
|
PLATFORMS
|
|
158
175
|
x86_64-darwin-18
|
|
@@ -160,11 +177,9 @@ PLATFORMS
|
|
|
160
177
|
|
|
161
178
|
DEPENDENCIES
|
|
162
179
|
activerecord-tidb-adapter!
|
|
163
|
-
bcrypt (~> 3.1)
|
|
164
180
|
byebug (~> 11.1)
|
|
165
181
|
minitest (~> 5.0)
|
|
166
182
|
minitest-excludes (~> 2.0)
|
|
167
|
-
mocha (~> 1.13)
|
|
168
183
|
pg (~> 1.2)
|
|
169
184
|
pry
|
|
170
185
|
rails!
|
data/README.md
CHANGED
|
@@ -8,7 +8,7 @@ TiDB adapter for ActiveRecord 5 and 6. This is a lightweight extension of the my
|
|
|
8
8
|
Add this line to your application's Gemfile:
|
|
9
9
|
|
|
10
10
|
```ruby
|
|
11
|
-
gem 'activerecord-tidb-adapter', "~>
|
|
11
|
+
gem 'activerecord-tidb-adapter', "~> 6.1.0"
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
And then execute:
|
|
@@ -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', '~>
|
|
32
|
+
spec.add_dependency 'activerecord', '~> 6.1'
|
|
33
33
|
spec.add_dependency 'mysql2'
|
|
34
34
|
|
|
35
35
|
# Uncomment to register a new dependency of your gem
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'active_record/connection_adapters'
|
|
3
4
|
require 'active_record/connection_adapters/mysql2_adapter'
|
|
4
5
|
require 'active_record/connection_adapters/tidb/setup'
|
|
5
6
|
require_relative '../../version'
|
|
6
7
|
require_relative '../sequence'
|
|
7
|
-
require_relative 'tidb/database_statements'
|
|
8
|
-
require_relative 'tidb/schema_statements'
|
|
9
8
|
|
|
10
9
|
ActiveRecord::ConnectionAdapters::Tidb.initial_setup
|
|
11
10
|
|
|
@@ -31,28 +30,7 @@ module ActiveRecord
|
|
|
31
30
|
end
|
|
32
31
|
end
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
36
33
|
module ConnectionAdapters
|
|
37
|
-
class Mysql2Adapter < AbstractMysqlAdapter
|
|
38
|
-
ER_BAD_DB_ERROR = 1049
|
|
39
|
-
ADAPTER_NAME = "Mysql2"
|
|
40
|
-
|
|
41
|
-
include MySQL::DatabaseStatements
|
|
42
|
-
|
|
43
|
-
class << self
|
|
44
|
-
def new_client(config)
|
|
45
|
-
Mysql2::Client.new(config)
|
|
46
|
-
rescue Mysql2::Error => error
|
|
47
|
-
if error.error_number == ConnectionAdapters::Mysql2Adapter::ER_BAD_DB_ERROR
|
|
48
|
-
raise ActiveRecord::NoDatabaseError
|
|
49
|
-
else
|
|
50
|
-
raise ActiveRecord::ConnectionNotEstablished, error.message
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
34
|
class TidbAdapter < Mysql2Adapter
|
|
57
35
|
include ActiveRecord::Sequence::Adapter
|
|
58
36
|
ADAPTER_NAME = 'Tidb'
|
|
@@ -121,6 +99,51 @@ module ActiveRecord
|
|
|
121
99
|
rescue ActiveRecord::NoDatabaseError
|
|
122
100
|
false
|
|
123
101
|
end
|
|
102
|
+
|
|
103
|
+
def insert(arel, name = nil, pk = nil, id_value = nil, sequence_name = nil, binds = [])
|
|
104
|
+
sql, binds = to_sql_and_binds(arel, binds)
|
|
105
|
+
value = exec_insert(sql, name, binds, pk, sequence_name)
|
|
106
|
+
return id_value if id_value.present?
|
|
107
|
+
|
|
108
|
+
model = arel.ast.relation.instance_variable_get(:@klass)
|
|
109
|
+
pk_def = schema_cache.columns_hash(model.table_name)[pk]
|
|
110
|
+
if pk_def&.default_function && pk_def.default_function =~ /nextval/
|
|
111
|
+
query_value("SELECT #{pk_def.default_function.sub('nextval', 'lastval')}")
|
|
112
|
+
elsif model.sequence_name
|
|
113
|
+
ActiveRecord::Base.lastval(model.sequence_name)
|
|
114
|
+
else
|
|
115
|
+
last_inserted_id(value)
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
alias create insert
|
|
119
|
+
|
|
120
|
+
def new_column_from_field(_table_name, field)
|
|
121
|
+
type_metadata = fetch_type_metadata(field[:Type], field[:Extra])
|
|
122
|
+
default = field[:Default]
|
|
123
|
+
default_function = nil
|
|
124
|
+
|
|
125
|
+
if type_metadata.type == :datetime && /\ACURRENT_TIMESTAMP(?:\([0-6]?\))?\z/i.match?(default)
|
|
126
|
+
default_function = default
|
|
127
|
+
default = nil
|
|
128
|
+
elsif type_metadata.extra == 'DEFAULT_GENERATED'
|
|
129
|
+
default = +"(#{default})" unless default.start_with?('(')
|
|
130
|
+
default_function = default
|
|
131
|
+
default = nil
|
|
132
|
+
elsif default.to_s =~ /nextval/i
|
|
133
|
+
default_function = default
|
|
134
|
+
default = nil
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
MySQL::Column.new(
|
|
138
|
+
field[:Field],
|
|
139
|
+
default,
|
|
140
|
+
type_metadata,
|
|
141
|
+
field[:Null] == 'YES',
|
|
142
|
+
default_function,
|
|
143
|
+
collation: field[:Collation],
|
|
144
|
+
comment: field[:Comment].presence
|
|
145
|
+
)
|
|
146
|
+
end
|
|
124
147
|
end
|
|
125
148
|
end
|
|
126
149
|
end
|
data/lib/version.rb
CHANGED
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:
|
|
4
|
+
version: 6.1.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-
|
|
11
|
+
date: 2021-08-19 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: '
|
|
19
|
+
version: '6.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: '
|
|
26
|
+
version: '6.1'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: mysql2
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -45,10 +45,6 @@ executables: []
|
|
|
45
45
|
extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
|
47
47
|
files:
|
|
48
|
-
- ".buildkite/hooks/pre-command"
|
|
49
|
-
- ".buildkite/pipeline.yml"
|
|
50
|
-
- ".github/entrypoint.sh"
|
|
51
|
-
- ".github/workflows/ci.yml"
|
|
52
48
|
- ".gitignore"
|
|
53
49
|
- Gemfile
|
|
54
50
|
- Gemfile.lock
|
|
@@ -59,9 +55,7 @@ files:
|
|
|
59
55
|
- bin/console
|
|
60
56
|
- bin/setup
|
|
61
57
|
- config.toml
|
|
62
|
-
- lib/active_record/connection_adapters/tidb/database_statements.rb
|
|
63
58
|
- lib/active_record/connection_adapters/tidb/database_tasks.rb
|
|
64
|
-
- lib/active_record/connection_adapters/tidb/schema_statements.rb
|
|
65
59
|
- lib/active_record/connection_adapters/tidb/setup.rb
|
|
66
60
|
- lib/active_record/connection_adapters/tidb/type.rb
|
|
67
61
|
- lib/active_record/connection_adapters/tidb_adapter.rb
|
|
@@ -72,7 +66,6 @@ files:
|
|
|
72
66
|
- lib/active_record/sequence/schema_dumper.rb
|
|
73
67
|
- lib/activerecord-tidb-adapter.rb
|
|
74
68
|
- lib/version.rb
|
|
75
|
-
- testing.sh
|
|
76
69
|
homepage: https://github.com/pingcap/activerecord-tidb-adapter
|
|
77
70
|
licenses:
|
|
78
71
|
- Apache-2.0
|
data/.buildkite/pipeline.yml
DELETED
data/.github/entrypoint.sh
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
set -eu
|
|
3
|
-
service supervisor start
|
|
4
|
-
|
|
5
|
-
while sleep 60; do
|
|
6
|
-
ps aux |grep tidb |grep -q -v grep
|
|
7
|
-
TIDB_STATUS=$?
|
|
8
|
-
ps aux |grep tikv |grep -q -v grep
|
|
9
|
-
TIKV_STATUS=$?
|
|
10
|
-
# If the greps above find anything, they exit with 0 status
|
|
11
|
-
# If they are not both 0, then something is wrong
|
|
12
|
-
if [ $TIDB_STATUS -ne 0 -o $TIKV_STATUS -ne 0 ]; then
|
|
13
|
-
echo "One of the processes has already exited."
|
|
14
|
-
exit 1
|
|
15
|
-
fi
|
|
16
|
-
done
|
data/.github/workflows/ci.yml
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
name: activerecord-tidb-adapter ci
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- 5-2-stable
|
|
7
|
-
paths-ignore:
|
|
8
|
-
- 'README*.md'
|
|
9
|
-
- 'docs/**'
|
|
10
|
-
pull_request:
|
|
11
|
-
branches:
|
|
12
|
-
- 5-2-stable
|
|
13
|
-
paths-ignore:
|
|
14
|
-
- 'README*.md'
|
|
15
|
-
- 'docs/**'
|
|
16
|
-
|
|
17
|
-
jobs:
|
|
18
|
-
build:
|
|
19
|
-
if: ${{ !contains(github.event.commits[0].message, '[skip ci]') }}
|
|
20
|
-
runs-on: ubuntu-latest
|
|
21
|
-
services:
|
|
22
|
-
tidb:
|
|
23
|
-
image: hawkingrei/tind:v5.1.0
|
|
24
|
-
options: --entrypoint /entrypoint.sh
|
|
25
|
-
env:
|
|
26
|
-
TIDB_VERSION: v5.1.0
|
|
27
|
-
ports: ["4000:4000"]
|
|
28
|
-
steps:
|
|
29
|
-
- uses: actions/checkout@v2
|
|
30
|
-
- uses: ruby/setup-ruby@v1
|
|
31
|
-
with:
|
|
32
|
-
ruby-version: 2.7
|
|
33
|
-
bundler-cache: true
|
|
34
|
-
- 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
|
|
35
|
-
- run: sleep 10 && MYSQL_USER=root MYSQL_HOST=127.0.0.1 MYSQL_PORT=4000 tidb=1 ARCONN=tidb bundle exec rake test:tidb
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
require 'active_record/connection_adapters/abstract/database_statements'
|
|
2
|
-
|
|
3
|
-
ActiveRecord::ConnectionAdapters::DatabaseStatements.class_eval do
|
|
4
|
-
def insert(arel, name = nil, pk = nil, id_value = nil, sequence_name = nil, binds = [])
|
|
5
|
-
sql, binds = to_sql_and_binds(arel, binds)
|
|
6
|
-
value = exec_insert(sql, name, binds, pk, sequence_name)
|
|
7
|
-
|
|
8
|
-
return id_value if id_value.present?
|
|
9
|
-
return last_inserted_id(value) if arel.is_a?(String)
|
|
10
|
-
table_name = arel.ast.relation.table_name
|
|
11
|
-
pk_def = schema_cache.columns_hash(table_name)[pk]
|
|
12
|
-
if pk_def&.default_function && pk_def.default_function =~ /nextval/
|
|
13
|
-
query_value("SELECT #{pk_def.default_function.sub('nextval', 'lastval')}")
|
|
14
|
-
else
|
|
15
|
-
last_inserted_id(value)
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
alias create insert
|
|
19
|
-
end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
require 'pry'
|
|
2
|
-
require 'active_record/connection_adapters/mysql/schema_statements'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
ActiveRecord::ConnectionAdapters::MySQL::SchemaStatements.class_eval do
|
|
6
|
-
def new_column_from_field(table_name, field)
|
|
7
|
-
type_metadata = fetch_type_metadata(field[:Type], field[:Extra])
|
|
8
|
-
if type_metadata.type == :datetime && /\ACURRENT_TIMESTAMP(?:\([0-6]?\))?\z/i.match?(field[:Default])
|
|
9
|
-
default, default_function = nil, field[:Default]
|
|
10
|
-
elsif field[:Default].to_s =~ /nextval/i
|
|
11
|
-
default_function = field[:Default]
|
|
12
|
-
default = nil
|
|
13
|
-
else
|
|
14
|
-
default, default_function = field[:Default], nil
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
ActiveRecord::ConnectionAdapters::MySQL::Column.new(
|
|
18
|
-
field[:Field],
|
|
19
|
-
default,
|
|
20
|
-
type_metadata,
|
|
21
|
-
field[:Null] == "YES",
|
|
22
|
-
table_name,
|
|
23
|
-
default_function,
|
|
24
|
-
field[:Collation],
|
|
25
|
-
comment: field[:Comment].presence
|
|
26
|
-
)
|
|
27
|
-
end
|
|
28
|
-
end
|
data/testing.sh
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
set -eo pipefail
|
|
4
|
-
|
|
5
|
-
bundle config set --local path '/tmp/buildkite-cache'
|
|
6
|
-
|
|
7
|
-
echo "Setup gem mirror"
|
|
8
|
-
bundle config mirror.https://rubygems.org https://gems.ruby-china.com
|
|
9
|
-
|
|
10
|
-
echo "Bundle install"
|
|
11
|
-
bundle install
|
|
12
|
-
|
|
13
|
-
echo "Setup database for testing"
|
|
14
|
-
tidb=1 ARCONN=tidb bundle exec rake db:tidb:rebuild && tidb=1 ARCONN=tidb bundle exec rake test:tidb
|