simple-sql 0.4.3 → 0.4.4
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 +4 -4
- data/.gitignore +2 -1
- data/Gemfile.lock +1 -1
- data/lib/simple/sql/scope.rb +8 -1
- data/lib/simple/sql/version.rb +1 -1
- data/scripts/watch +1 -1
- data/spec/simple/sql_scope_spec.rb +25 -0
- data/spec/spec_helper.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dc4e5192271e99151c59877f89671f27f3333e6
|
4
|
+
data.tar.gz: 986e1c338ed8c7c9571ea85797fd0f6444a8d8b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84e6f1f3e6bad60ca3611d103a84db49069132c07f3142a88764b8fd402daea2dff9b77ac2c1d2cd72eeddf4934b1441400486eeed430744423e65be014ca866
|
7
|
+
data.tar.gz: 4d41a55a04b5f24cb0088fc4dd89badfdf510c7a2c06d8c64cafc3a50b3a414c8a01e66c75e245a179e527c561f5aa079f46454836cb1c5de88194ac0a7afd1c
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/lib/simple/sql/scope.rb
CHANGED
@@ -54,7 +54,14 @@ class Simple::SQL::Scope
|
|
54
54
|
|
55
55
|
def where!(sql_fragment, arg = :__dummy__no__arg, placeholder: "?")
|
56
56
|
if arg == :__dummy__no__arg
|
57
|
-
|
57
|
+
if sql_fragment.is_a?(Hash)
|
58
|
+
sql_fragment.each do |key, value|
|
59
|
+
@args << value
|
60
|
+
@filters << "#{key} = $#{@args.length}"
|
61
|
+
end
|
62
|
+
else
|
63
|
+
@filters << sql_fragment
|
64
|
+
end
|
58
65
|
else
|
59
66
|
@args << arg
|
60
67
|
@filters << sql_fragment.gsub(placeholder, "$#{@args.length}")
|
data/lib/simple/sql/version.rb
CHANGED
data/scripts/watch
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
#!/bin/bash
|
2
|
-
watchr lib,spec rspec
|
2
|
+
watchr lib,spec 'rspec --only-failures ; [[ $? == 2 ]] && rspec'
|
@@ -25,6 +25,31 @@ describe "Simple::SQL::Scope" do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
context "with hash conditions" do
|
29
|
+
let(:user_id) { SQL.ask "SELECT id FROM users LIMIT 1" }
|
30
|
+
let(:scope) { SQL::Scope.new "SELECT 1 FROM users" }
|
31
|
+
|
32
|
+
context "that do not match" do
|
33
|
+
it "does not match with string keys" do
|
34
|
+
expect(SQL.ask(scope.where(id: -1))).to be_nil
|
35
|
+
end
|
36
|
+
|
37
|
+
it "does not match with symbol keys" do
|
38
|
+
expect(SQL.ask(scope.where("id" => -1))).to be_nil
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "that match" do
|
43
|
+
it "matches with string keys" do
|
44
|
+
expect(SQL.ask(scope.where("id" => user_id))).to eq(1)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "matches with symbol keys" do
|
48
|
+
expect(SQL.ask(scope.where(id: user_id))).to eq(1)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
28
53
|
context "with non-argument conditions" do
|
29
54
|
context "that do not match" do
|
30
55
|
let(:scope) do
|
data/spec/spec_helper.rb
CHANGED
@@ -27,6 +27,8 @@ RSpec.configure do |config|
|
|
27
27
|
config.filter_run focus: (ENV["CI"] != "true")
|
28
28
|
config.expect_with(:rspec) { |c| c.syntax = :expect }
|
29
29
|
config.order = "random"
|
30
|
+
config.example_status_persistence_file_path = ".rspec.data"
|
31
|
+
|
30
32
|
config.around(:each) do |example|
|
31
33
|
Simple::SQL.ask "DELETE FROM users"
|
32
34
|
Simple::SQL.ask "DELETE FROM unique_users"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple-sql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- radiospiel
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-05-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pg_array_parser
|