activerecord-memsql 1.0.0 → 1.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 +5 -5
- data/lib/active_record/connection_adapters/memsql_adapter.rb +44 -22
- metadata +7 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 184a17492e053c82784b1a58af061529af17fe4736b887d7e7af98cc154380d4
|
4
|
+
data.tar.gz: 3541951f22a4129dc640a0625665c4ae33a4107312733d70e0ea48f47306db83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdcb8cf3b3d6fe261495f675109f658e3aad7d15bc72c021378ec41f8c3d9d8e2e17ba0154e12bdcebd8b4b8c8dd23de935bdb7fb153ed4e722df2295cc009c1
|
7
|
+
data.tar.gz: 0be1ef4c41cacd3354739ab24bb54c61e81a0cf5fa5bde993ac6c2a7e3fe13b578c0db4b8d20bf56d20da1c726a46dffc57cd64ffcf9f5ede0ec55d028f3c443
|
@@ -1,13 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "active_record/connection_adapters/abstract_mysql_adapter"
|
2
4
|
require "active_record/connection_adapters/mysql2_adapter"
|
3
5
|
require "active_record/connection_adapters/mysql/database_statements"
|
4
6
|
|
5
|
-
gem "mysql2", ">= 0.
|
6
|
-
require "mysql2"
|
7
|
-
raise "mysql2 0.4.3 is not supported. Please upgrade to 0.4.4+" if Mysql2::VERSION == "0.4.3"
|
7
|
+
gem "mysql2", ">= 0.4.4"
|
8
8
|
|
9
9
|
module ActiveRecord
|
10
10
|
module ConnectionHandling # :nodoc:
|
11
|
+
ER_BAD_DB_ERROR = 1049
|
12
|
+
|
11
13
|
# Establishes a connection to the database that's used by all Active Record objects.
|
12
14
|
def memsql_connection(config)
|
13
15
|
config = config.symbolize_keys
|
@@ -17,15 +19,15 @@ module ActiveRecord
|
|
17
19
|
config[:variables] = {sql_mode: ''} if config[:variables].nil?
|
18
20
|
|
19
21
|
if config[:flags].kind_of? Array
|
20
|
-
config[:flags].push "FOUND_ROWS"
|
22
|
+
config[:flags].push "FOUND_ROWS"
|
21
23
|
else
|
22
24
|
config[:flags] |= Mysql2::Client::FOUND_ROWS
|
23
25
|
end
|
24
26
|
|
25
27
|
client = Mysql2::Client.new(config)
|
26
|
-
ConnectionAdapters::
|
28
|
+
ConnectionAdapters::MemsqlAdapter.new(client, logger, nil, config)
|
27
29
|
rescue Mysql2::Error => error
|
28
|
-
if error.
|
30
|
+
if error.error_number == ER_BAD_DB_ERROR
|
29
31
|
raise ActiveRecord::NoDatabaseError
|
30
32
|
else
|
31
33
|
raise
|
@@ -35,18 +37,24 @@ module ActiveRecord
|
|
35
37
|
|
36
38
|
module ConnectionAdapters
|
37
39
|
class MemsqlAdapter < AbstractMysqlAdapter
|
38
|
-
ADAPTER_NAME = "MemSQL"
|
40
|
+
ADAPTER_NAME = "MemSQL"
|
39
41
|
|
40
42
|
include MySQL::DatabaseStatements
|
41
43
|
|
42
44
|
def initialize(connection, logger, connection_options, config)
|
43
|
-
|
44
|
-
|
45
|
+
superclass_config = config.reverse_merge(prepared_statements: false)
|
46
|
+
super(connection, logger, connection_options, superclass_config)
|
45
47
|
configure_connection
|
46
48
|
end
|
47
49
|
|
50
|
+
def self.database_exists?(config)
|
51
|
+
!!ActiveRecord::Base.memsql_connection(config)
|
52
|
+
rescue ActiveRecord::NoDatabaseError
|
53
|
+
false
|
54
|
+
end
|
55
|
+
|
48
56
|
def supports_json?
|
49
|
-
!mariadb? &&
|
57
|
+
!mariadb? && database_version >= "5.7.8"
|
50
58
|
end
|
51
59
|
|
52
60
|
def supports_comments?
|
@@ -61,6 +69,10 @@ module ActiveRecord
|
|
61
69
|
true
|
62
70
|
end
|
63
71
|
|
72
|
+
def supports_lazy_transactions?
|
73
|
+
true
|
74
|
+
end
|
75
|
+
|
64
76
|
def supports_advisory_locks?
|
65
77
|
false
|
66
78
|
end
|
@@ -111,21 +123,31 @@ module ActiveRecord
|
|
111
123
|
@connection.close
|
112
124
|
end
|
113
125
|
|
126
|
+
def discard! # :nodoc:
|
127
|
+
super
|
128
|
+
@connection.automatic_close = false
|
129
|
+
@connection = nil
|
130
|
+
end
|
131
|
+
|
114
132
|
private
|
115
133
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
134
|
+
def connect
|
135
|
+
@connection = Mysql2::Client.new(@config)
|
136
|
+
configure_connection
|
137
|
+
end
|
120
138
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
139
|
+
def configure_connection
|
140
|
+
@connection.query_options[:as] = :array
|
141
|
+
super
|
142
|
+
end
|
125
143
|
|
126
|
-
|
127
|
-
|
128
|
-
|
144
|
+
def full_version
|
145
|
+
schema_cache.database_version.full_version_string
|
146
|
+
end
|
147
|
+
|
148
|
+
def get_full_version
|
149
|
+
@connection.server_info[:version]
|
150
|
+
end
|
129
151
|
end
|
130
152
|
end
|
131
|
-
end
|
153
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-memsql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Geselle
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,34 +58,28 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 6.0.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 6.0.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: mysql2
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.4.
|
76
|
-
- - "<"
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
version: '0.5'
|
75
|
+
version: 0.4.4
|
79
76
|
type: :runtime
|
80
77
|
prerelease: false
|
81
78
|
version_requirements: !ruby/object:Gem::Requirement
|
82
79
|
requirements:
|
83
80
|
- - ">="
|
84
81
|
- !ruby/object:Gem::Version
|
85
|
-
version: 0.4.
|
86
|
-
- - "<"
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: '0.5'
|
82
|
+
version: 0.4.4
|
89
83
|
description: "The ActiveRecod MemSQL Adapter is an ActiveRecord connection adapter
|
90
84
|
based on the standard mysql2 adapter.\nThis adapter is a customized version of the
|
91
85
|
mysql2 adapter to provide support for MemSQL. "
|
@@ -116,8 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
110
|
- !ruby/object:Gem::Version
|
117
111
|
version: '0'
|
118
112
|
requirements: []
|
119
|
-
|
120
|
-
rubygems_version: 2.6.11
|
113
|
+
rubygems_version: 3.1.2
|
121
114
|
signing_key:
|
122
115
|
specification_version: 4
|
123
116
|
summary: ActiveRecord MemSQL Adapter
|