mysql_framework 2.1.4 → 2.1.7
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7cfae16762fc02981eed438b941a6eddbf69df7f24d7d7a6c390604064518da
|
4
|
+
data.tar.gz: aba1911d97941727399a9bd815df8453b276761c736ced329298f8c18b65f69e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee9ad256b44ed8ec1db8b9039a72324d3045d5e5b2063c88d64605f63c3bf089d4da383cb1ebece12027dea5a20a7d98734e90192874ce2340244286cea2a0fc
|
7
|
+
data.tar.gz: 5d867a1db81ccb22887246584ee8020a934e88f11bc5f434ff07e5a1100c89601d13e151406b9c924073a46c72ca3d26b82a4965a1bb02c846cd3239bfc66ebc
|
@@ -44,10 +44,25 @@ module MysqlFramework
|
|
44
44
|
|
45
45
|
def index_exists?(client, table_name, index_name)
|
46
46
|
result = client.query(<<~SQL)
|
47
|
-
SHOW INDEX FROM #{table_name} WHERE Key_name="#{index_name}"
|
47
|
+
SHOW INDEX FROM #{table_name} WHERE Key_name="#{index_name}";
|
48
48
|
SQL
|
49
49
|
|
50
|
-
result.count
|
50
|
+
result.count >= 1
|
51
|
+
end
|
52
|
+
|
53
|
+
def index_up_to_date?(client, table_name, index_name, columns)
|
54
|
+
result = client.query(<<~SQL)
|
55
|
+
SHOW INDEX FROM #{table_name} WHERE Key_name="#{index_name}";
|
56
|
+
SQL
|
57
|
+
|
58
|
+
return false if result.size != columns.size
|
59
|
+
|
60
|
+
index_columns = result.sort_by { |column| column[:Seq_in_index] }
|
61
|
+
index_columns.each_with_index do |column, i|
|
62
|
+
return false if column[:Column_name] != columns[i]
|
63
|
+
end
|
64
|
+
|
65
|
+
true
|
51
66
|
end
|
52
67
|
|
53
68
|
protected
|
@@ -86,4 +86,28 @@ describe MysqlFramework::Scripts::Base do
|
|
86
86
|
expect(subject.index_exists?(client,'foo','bar')).to eq(false)
|
87
87
|
end
|
88
88
|
end
|
89
|
+
|
90
|
+
describe '#index_up_to_date?' do
|
91
|
+
before do
|
92
|
+
expect(client).to receive(:query).and_return(
|
93
|
+
[{ Column_name: 'b', Seq_in_index: 2 }, { Column_name: 'a', Seq_in_index: 1 }]
|
94
|
+
)
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'returns true when index is up to date' do
|
98
|
+
expect(subject.index_up_to_date?(client, 'foo', 'bar', ['a', 'b'])).to eq(true)
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'returns false when index is missing a column' do
|
102
|
+
expect(subject.index_up_to_date?(client, 'foo', 'bar', ['a', 'b', 'c'])).to eq(false)
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'returns false when index is having too many columns' do
|
106
|
+
expect(subject.index_up_to_date?(client, 'foo', 'bar', ['a'])).to eq(false)
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'returns false when index has columns in wrong order' do
|
110
|
+
expect(subject.index_up_to_date?(client, 'foo', 'bar', ['b', 'a'])).to eq(false)
|
111
|
+
end
|
112
|
+
end
|
89
113
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mysql_framework
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sage
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
requirements: []
|
140
|
-
rubygems_version: 3.
|
140
|
+
rubygems_version: 3.3.5
|
141
141
|
signing_key:
|
142
142
|
specification_version: 4
|
143
143
|
summary: A lightweight framework to provide managers for working with MySQL.
|