where_exists 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/where_exists.rb +5 -1
- data/lib/where_exists/version.rb +1 -1
- data/test/belongs_to_polymorphic_test.rb +12 -0
- data/test/db/test.db +0 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 397b2a3fc406fb516d6f060ae46b25580a764c668476859737ee07fbd979c15b
|
4
|
+
data.tar.gz: 1c23ab279b89ede28edb71e3b951f7587ab2a7b27605bba607888f0b89e03c58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 454c6302e62cbc669c8d800bab1305b2e83402f46ed2499a4caf373cfaa23547cbaf261163fc28cd2fe224a31c7f5bb927a5baf09deb04c856de49c481b5fc75
|
7
|
+
data.tar.gz: b32e53db604284721d96afd9b1fa7ac204277dda4cc27f4851ac1918760980fa64c17392917ca770a712541f5ab132bedaa2f0f102ac6c20fa50354d16e18ad1
|
data/lib/where_exists.rb
CHANGED
@@ -20,7 +20,11 @@ module WhereExists
|
|
20
20
|
not_string = "NOT "
|
21
21
|
end
|
22
22
|
|
23
|
-
|
23
|
+
if queries_sql.empty?
|
24
|
+
does_exist ? self.none : self.all
|
25
|
+
else
|
26
|
+
self.where("#{not_string}(#{queries_sql})")
|
27
|
+
end
|
24
28
|
end
|
25
29
|
|
26
30
|
def build_exists_string(association_name, *where_parameters, &block)
|
data/lib/where_exists/version.rb
CHANGED
@@ -61,6 +61,18 @@ class BelongsToPolymorphicTest < Minitest::Test
|
|
61
61
|
assert_equal orphaned_child.id, result.first.id
|
62
62
|
end
|
63
63
|
|
64
|
+
def test_no_entities_or_empty_child_relation
|
65
|
+
result = BelongsToPolymorphicChild.where_not_exists(:polymorphic_entity)
|
66
|
+
assert_equal 0, result.length
|
67
|
+
|
68
|
+
_first_child = BelongsToPolymorphicChild.create!
|
69
|
+
result = BelongsToPolymorphicChild.where_not_exists(:polymorphic_entity)
|
70
|
+
assert_equal 1, result.length
|
71
|
+
|
72
|
+
result = BelongsToPolymorphicChild.where_exists(:polymorphic_entity)
|
73
|
+
assert_equal 0, result.length
|
74
|
+
end
|
75
|
+
|
64
76
|
def test_table_name_based_lookup
|
65
77
|
first_entity = FirstPolymorphicEntity.create!
|
66
78
|
second_entity = SecondPolymorphicEntity.create! id: first_entity.id + 1
|
data/test/db/test.db
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: where_exists
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eugene Zolotarev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
126
|
- !ruby/object:Gem::Version
|
127
127
|
version: '0'
|
128
128
|
requirements: []
|
129
|
-
rubygems_version: 3.
|
129
|
+
rubygems_version: 3.1.2
|
130
130
|
signing_key:
|
131
131
|
specification_version: 4
|
132
132
|
summary: "#where_exists extension of ActiveRecord"
|