activerecord-tidb-adapter 0.1.1 → 0.2.0

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: 4ee75804c5fe17ede37170f3856799e9ecd695aeb485ff1d41884e2cf92f3f8c
4
- data.tar.gz: c59c71505842a93e360841d1607b8ce10eb5cbaa4cec4e0fef960cec7b619f18
3
+ metadata.gz: 8ad173cdbfab54d867f0116350b372fc06224abb5c3166da8d59dcbe59125d5e
4
+ data.tar.gz: 03a849590718d9d94f9d59730d51f001050c00ad09d54ba7dcd9470625627dd1
5
5
  SHA512:
6
- metadata.gz: bb073e2194896f6327234862b90c1511a9ffcf63ca4bdda8073fd24b321bbc3227f920cd3a2fb11aacab2cd2ff281b1f4526eae3f1cf6bb93f4fe75da08ca15b
7
- data.tar.gz: 310d87aac24163da5443928c41240cab11d6bdf1acabe9ec46cbf2e7af62b55c74054f46369b8e9eefda05d805af8a5cb2057afa1f0e8be75a369fd39771c2cd
6
+ metadata.gz: 86b8d677d14434d8db2c688caf99946bbc8357d729abcdea9c707330f792cd190cebdfd47b7e9305154ed41399fdaf0315b9f5d718217c922c92faecbcaf80d0
7
+ data.tar.gz: 563c533e208b02539137b94f5b0e4f6939114dacec5a04524e31744bd8267ead0db261d4e04e02c997b3a2d9646959d56c095aa7be72974cbfa67b91f20a9d9c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- activerecord-tidb-adapter (0.1.1)
4
+ activerecord-tidb-adapter (0.2.0)
5
5
  activerecord (~> 6.1)
6
6
  mysql2
7
7
 
@@ -0,0 +1,9 @@
1
+ module ActiveRecord
2
+ module Type
3
+ class << self
4
+ def adapter_name_from(_model)
5
+ :mysql
6
+ end
7
+ end
8
+ end
9
+ end
@@ -32,6 +32,75 @@ module ActiveRecord
32
32
  module ConnectionAdapters
33
33
  class TidbAdapter < Mysql2Adapter
34
34
  ADAPTER_NAME = 'Tidb'
35
+
36
+ def supports_savepoints?
37
+ false
38
+ end
39
+
40
+ def supports_foreign_keys?
41
+ false
42
+ end
43
+
44
+ def supports_bulk_alter?
45
+ false
46
+ end
47
+
48
+ def supports_advisory_locks?
49
+ false
50
+ end
51
+
52
+ def supports_optimizer_hints?
53
+ true
54
+ end
55
+
56
+ def supports_json?
57
+ true
58
+ end
59
+
60
+ def supports_index_sort_order?
61
+ # TODO: check TiDB version
62
+ true
63
+ end
64
+
65
+ def supports_expression_index?
66
+ true
67
+ end
68
+
69
+ def supports_common_table_expressions?
70
+ if tidb_version >= '5.1.0'
71
+ true
72
+ else
73
+ false
74
+ end
75
+ end
76
+
77
+ def transaction_isolation_levels
78
+ {
79
+ read_committed: 'READ COMMITTED',
80
+ repeatable_read: 'REPEATABLE READ'
81
+ }
82
+ end
83
+
84
+ def initialize(connection, logger, conn_params, config)
85
+ super(connection, logger, conn_params, config)
86
+
87
+ tidb_version_string = query_value('select version()')
88
+ @tidb_version = tidb_version_string[/TiDB-v([0-9\.]+)/, 1]
89
+ end
90
+
91
+ def tidb_version_string
92
+ @tidb_version
93
+ end
94
+
95
+ def tidb_version
96
+ Version.new(tidb_version_string)
97
+ end
98
+
99
+ def self.database_exists?(config)
100
+ !!ActiveRecord::Base.tidb_connection(config)
101
+ rescue ActiveRecord::NoDatabaseError
102
+ false
103
+ end
35
104
  end
36
105
  end
37
106
  end
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.1.1'
4
+ TIDB_ADAPTER_VERSION = '0.2.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.1.1
4
+ version: 0.2.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-06 00:00:00.000000000 Z
11
+ date: 2021-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -57,6 +57,7 @@ files:
57
57
  - bin/setup
58
58
  - lib/active_record/connection_adapters/tidb/database_tasks.rb
59
59
  - lib/active_record/connection_adapters/tidb/setup.rb
60
+ - lib/active_record/connection_adapters/tidb/type.rb
60
61
  - lib/active_record/connection_adapters/tidb_adapter.rb
61
62
  - lib/activerecord-tidb-adapter.rb
62
63
  - lib/version.rb