mysql_framework 2.1.5 → 2.1.8
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 243312b0bb9c568e535dd002ebcf30b8896d433067a10bfdf781ba2c2b47d2c7
|
4
|
+
data.tar.gz: 62bbf2d7b89889902ecd781050b0ebbb1a4f7c79a6095ba652d92ce7c644b833
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fc999ca91c3f06506e0aa41b9ac8c30a23b0322458db992a3849e4842a2045c95605e1994cc0d4a56d01f4e5bd6d910d49a159aebcb157b0150361393d1a174
|
7
|
+
data.tar.gz: cd9341f57273a1fb72eb3a2c61c1e4837a2966fb04ad41fb6157f39a33b840ae3356d1b3671a80d08a2d86baae89e4c42d7c9876c13d7214c8574c3a1516f339
|
@@ -50,6 +50,21 @@ module MysqlFramework
|
|
50
50
|
result.count >= 1
|
51
51
|
end
|
52
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
|
66
|
+
end
|
67
|
+
|
53
68
|
protected
|
54
69
|
|
55
70
|
def generate_partition_sql
|
@@ -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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sage
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|