mysql_framework 0.1.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mysql_framework/scripts/base.rb +16 -0
- data/lib/mysql_framework/version.rb +1 -1
- data/spec/lib/mysql_framework/scripts/base_spec.rb +24 -0
- metadata +3 -6
- data/bin/console +0 -14
- data/bin/setup +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 868711b6057c83666f750ab7a4e8f2ec077066feecc455433fec836ab7ee4acd
|
4
|
+
data.tar.gz: 659285307152ca7a9c857743bd9f11c6f1724bbce1ce59ae8aff7f13da1de4bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffc7cb6ffc5d61bccebb31be7c7977556e296294be8738a6328e69756cabdfe743a4f2593af891fcce3e4818b5fa4ed0ada2de86303495d0c9d4c8549934b988
|
7
|
+
data.tar.gz: b6ad5342c8b61914f3869f1e53b2af7035733bdd16f132943d7ebea0efdd0fd8d8fdd3a238ae655436261f6417bea513f5543056441c0eead991c7c63bab2222
|
@@ -34,6 +34,22 @@ module MysqlFramework
|
|
34
34
|
client.query(proc_sql)
|
35
35
|
end
|
36
36
|
|
37
|
+
def column_exists?(client, table_name, column_name)
|
38
|
+
result = client.query(<<~SQL)
|
39
|
+
SHOW COLUMNS FROM '#{table_name}' WHERE Field='#{column_name}';
|
40
|
+
SQL
|
41
|
+
|
42
|
+
result.count == 1
|
43
|
+
end
|
44
|
+
|
45
|
+
def index_exists?(client, table_name, index_name)
|
46
|
+
result = client.query(<<~SQL)
|
47
|
+
SHOW INDEX FROM '#{table_name}' WHERE Key_name='#{index_name}' LIMIT 1;
|
48
|
+
SQL
|
49
|
+
|
50
|
+
result.count == 1
|
51
|
+
end
|
52
|
+
|
37
53
|
protected
|
38
54
|
|
39
55
|
def generate_partition_sql
|
@@ -62,4 +62,28 @@ describe MysqlFramework::Scripts::Base do
|
|
62
62
|
subject.update_procedure(client, 'test_procedure', proc_file_path)
|
63
63
|
end
|
64
64
|
end
|
65
|
+
|
66
|
+
describe '#column_exists?' do
|
67
|
+
it 'returns true when column exists' do
|
68
|
+
expect(client).to receive(:query).and_return(['result'])
|
69
|
+
expect(subject.column_exists?(client,'foo','bar')).to eq(true)
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'returns false when column does not exist' do
|
73
|
+
expect(client).to receive(:query).and_return([])
|
74
|
+
expect(subject.column_exists?(client,'foo','bar')).to eq(false)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#index_exists?' do
|
79
|
+
it 'returns true when index exists' do
|
80
|
+
expect(client).to receive(:query).and_return(['result'])
|
81
|
+
expect(subject.index_exists?(client,'foo','bar')).to eq(true)
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'returns false when index does not exist' do
|
85
|
+
expect(client).to receive(:query).and_return([])
|
86
|
+
expect(subject.index_exists?(client,'foo','bar')).to eq(false)
|
87
|
+
end
|
88
|
+
end
|
65
89
|
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: 0.
|
4
|
+
version: 1.0.0
|
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: 2019-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -101,8 +101,6 @@ executables: []
|
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
|
-
- bin/console
|
105
|
-
- bin/setup
|
106
104
|
- lib/mysql_framework.rb
|
107
105
|
- lib/mysql_framework/connector.rb
|
108
106
|
- lib/mysql_framework/logger.rb
|
@@ -152,8 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
150
|
- !ruby/object:Gem::Version
|
153
151
|
version: '0'
|
154
152
|
requirements: []
|
155
|
-
|
156
|
-
rubygems_version: 2.7.8
|
153
|
+
rubygems_version: 3.0.3
|
157
154
|
signing_key:
|
158
155
|
specification_version: 4
|
159
156
|
summary: A lightweight framework to provide managers for working with MySQL.
|
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "dynamodb_framework"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start
|