spare 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/spare/core.rb +1 -1
- data/lib/spare/exceptions.rb +4 -0
- data/lib/spare/mysql_abstract_adapter.rb +5 -4
- data/lib/spare/version.rb +1 -1
- data/lib/spare.rb +1 -0
- data/spec/lib/spare/mysql_abstract_adapter_spec.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6133fdf40c180092996247c0206ff5278ff0166
|
4
|
+
data.tar.gz: b608da7b494052e5b256c79430a0e981cd44fcb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64c4fe6d1b26abef7503887f555df388c36cb9045f7002406c3e3072fa5d08d261884c94de93a703aa81c05e881a8b6520f522d9cdcca3eecc190704fe66bfda
|
7
|
+
data.tar.gz: 0252c0c7438670edc38276a9c1e232ddf02ef15debbbf512611f4ef09cc4ad4d27b5253616f67fe4a0a6189df74e4aacca6660bab7d27603c3d9d9ace1d9be04
|
data/lib/spare/core.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'spare/exceptions'
|
1
2
|
require 'active_record/connection_adapters/abstract_mysql_adapter'
|
2
3
|
module ActiveRecord
|
3
4
|
module ConnectionAdapters
|
@@ -5,15 +6,15 @@ module ActiveRecord
|
|
5
6
|
|
6
7
|
# Returns hash describing the stored procedure.
|
7
8
|
def stored_procedure(name)#:nodoc:
|
8
|
-
|
9
|
+
sp_name = name.split('.').reverse
|
9
10
|
|
10
|
-
sql = "SELECT db,specific_name,param_list,db_collation FROM mysql.proc WHERE specific_name = #{quote(
|
11
|
-
sql << " AND db = #{quote(
|
11
|
+
sql = "SELECT db,specific_name,param_list,db_collation FROM mysql.proc WHERE specific_name = #{quote(sp_name[0])}"
|
12
|
+
sql << " AND db = #{quote(sp_name[1])}" if sp_name[1]
|
12
13
|
|
13
14
|
result = execute(sql)
|
14
15
|
keys = result.fields.collect{|k| k.to_sym}
|
15
16
|
values = result.to_a[0]
|
16
|
-
|
17
|
+
raise ActiveRecord::StoredProcedureNotFound, "#{name} was not found" unless values
|
17
18
|
sp = Hash[keys.zip(values)]
|
18
19
|
sp[:param_list] = stored_procedure_params(sp[:param_list], sp[:db_collation])
|
19
20
|
sp
|
data/lib/spare/version.rb
CHANGED
data/lib/spare.rb
CHANGED
@@ -4,7 +4,7 @@ describe ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter do
|
|
4
4
|
describe '#stored_procedure' do
|
5
5
|
|
6
6
|
context "stored procedure does not exist" do
|
7
|
-
it {expect
|
7
|
+
it {expect {ActiveRecord::Base.connection.stored_procedure("bad")}.to raise_error(ActiveRecord::StoredProcedureNotFound) }
|
8
8
|
end
|
9
9
|
|
10
10
|
context "stored procedure does exist" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spare
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Mckinney
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -138,6 +138,7 @@ files:
|
|
138
138
|
- lib/spare.rb
|
139
139
|
- lib/spare/attributes.rb
|
140
140
|
- lib/spare/core.rb
|
141
|
+
- lib/spare/exceptions.rb
|
141
142
|
- lib/spare/model_schema.rb
|
142
143
|
- lib/spare/mysql_abstract_adapter.rb
|
143
144
|
- lib/spare/schema_cache.rb
|