squint 0.0.3 → 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/.all-contributorsrc +86 -0
- data/lib/squint.rb +96 -74
- data/lib/squint/version.rb +1 -1
- data/readme.md +185 -0
- data/test/dummy/config/application.rb +3 -1
- data/test/dummy/config/environments/test.rb +7 -2
- data/test/dummy/log/development.log +39 -0
- data/test/dummy/log/test.log +62346 -0
- data/test/reports/TEST-SquintTest.xml +57 -0
- data/test/squint_test.rb +18 -14
- data/test/test_helper.rb +5 -1
- metadata +23 -7
- data/test/dummy/test/models/post_test.rb +0 -4
@@ -0,0 +1,57 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<testsuite time='0.331061' skipped='0' failures='0' errors='0' name="SquintTest" assertions='31' tests='27'>
|
3
|
+
<testcase time='0.024645' file="test/squint_test.rb" name="test_detects_default_integer_storext_jsonb_attributes" assertions='1'>
|
4
|
+
</testcase>
|
5
|
+
<testcase time='0.010476' file="test/squint_test.rb" name="test_detects_present_storext_jsonb_attributes" assertions='1'>
|
6
|
+
</testcase>
|
7
|
+
<testcase time='0.010010' file="test/squint_test.rb" name="test_detects_default_Falseclass_storext_jsonb_attributes" assertions='1'>
|
8
|
+
</testcase>
|
9
|
+
<testcase time='0.009655' file="test/squint_test.rb" name="test_finds_records_for_properties_populated" assertions='1'>
|
10
|
+
</testcase>
|
11
|
+
<testcase time='0.012391' file="test/squint_test.rb" name="test_detects_default_integer_storext_hstore_attributes" assertions='1'>
|
12
|
+
</testcase>
|
13
|
+
<testcase time='0.015957' file="test/squint_test.rb" name="test_finds_records_for_request_info_populated_with_array" assertions='1'>
|
14
|
+
</testcase>
|
15
|
+
<testcase time='0.012892' file="test/squint_test.rb" name="test_generates_SQL_for_properties" assertions='2'>
|
16
|
+
</testcase>
|
17
|
+
<testcase time='0.010305' file="test/squint_test.rb" name="test_finds_records_for_properties_populated_with_array" assertions='1'>
|
18
|
+
</testcase>
|
19
|
+
<testcase time='0.012353' file="test/squint_test.rb" name="test_finds_records_for_properties_with_nil" assertions='1'>
|
20
|
+
</testcase>
|
21
|
+
<testcase time='0.019733' file="test/squint_test.rb" name="test_handles_multiple_non-hash_parameters" assertions='1'>
|
22
|
+
</testcase>
|
23
|
+
<testcase time='0.011406' file="test/squint_test.rb" name="test_Doesn't_find_records_for_properties_missing_element_that_doesn't_exist_populated" assertions='1'>
|
24
|
+
</testcase>
|
25
|
+
<testcase time='0.009941' file="test/squint_test.rb" name="test_detects_default_Falseclass_storext_hstore_attributes" assertions='1'>
|
26
|
+
</testcase>
|
27
|
+
<testcase time='0.009810' file="test/squint_test.rb" name="test_finds_records_for_request_info_populated" assertions='1'>
|
28
|
+
</testcase>
|
29
|
+
<testcase time='0.015859' file="test/squint_test.rb" name="test_storext_jsonb_attributes_is_composeable_in_multiple_wheres" assertions='2'>
|
30
|
+
</testcase>
|
31
|
+
<testcase time='0.010980' file="test/squint_test.rb" name="test_detects_default_storext_jsonb_attributes" assertions='1'>
|
32
|
+
</testcase>
|
33
|
+
<testcase time='0.010904' file="test/squint_test.rb" name="test_detects_present_integer_storext_hstore_attributes" assertions='1'>
|
34
|
+
</testcase>
|
35
|
+
<testcase time='0.010792' file="test/squint_test.rb" name="test_finds_records_for_properties_populated_with_array_including_nil" assertions='1'>
|
36
|
+
</testcase>
|
37
|
+
<testcase time='0.009264' file="test/squint_test.rb" name="test_finds_records_for_request_info_populated_with_array_including_nil" assertions='1'>
|
38
|
+
</testcase>
|
39
|
+
<testcase time='0.015336' file="test/squint_test.rb" name="test_storext_jsonb_attributes_is_composeable_in_one_where" assertions='2'>
|
40
|
+
</testcase>
|
41
|
+
<testcase time='0.010052' file="test/squint_test.rb" name="test_detects_present_integer_storext_jsonb_attributes" assertions='1'>
|
42
|
+
</testcase>
|
43
|
+
<testcase time='0.011171' file="test/squint_test.rb" name="test_detects_default_storext_hstore_attributes" assertions='1'>
|
44
|
+
</testcase>
|
45
|
+
<testcase time='0.010303' file="test/squint_test.rb" name="test_finds_records_for_request_info_missing_element_that_doesn't_exist_with_nil" assertions='1'>
|
46
|
+
</testcase>
|
47
|
+
<testcase time='0.009981' file="test/squint_test.rb" name="test_Doesn't_find_records_for_request_info_missing_element_that_doesn't_exist_populated" assertions='1'>
|
48
|
+
</testcase>
|
49
|
+
<testcase time='0.011758' file="test/squint_test.rb" name="test_finds_records_for_properties_missing_element_that_doesn't_exist_with_nil" assertions='1'>
|
50
|
+
</testcase>
|
51
|
+
<testcase time='0.011404' file="test/squint_test.rb" name="test_finds_records_for_request_info_with_nil" assertions='1'>
|
52
|
+
</testcase>
|
53
|
+
<testcase time='0.012454' file="test/squint_test.rb" name="test_generates_SQL_for_request_info" assertions='2'>
|
54
|
+
</testcase>
|
55
|
+
<testcase time='0.011229' file="test/squint_test.rb" name="test_handles_string_parameters" assertions='1'>
|
56
|
+
</testcase>
|
57
|
+
</testsuite>
|
data/test/squint_test.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class SquintTest < ActiveSupport::TestCase
|
4
|
-
self.use_transactional_fixtures = true
|
5
4
|
|
6
5
|
# Tests that should pass for both jsonb and hstore properties
|
7
6
|
%i[request_info properties].each do |prop_name|
|
@@ -45,19 +44,21 @@ class SquintTest < ActiveSupport::TestCase
|
|
45
44
|
end
|
46
45
|
end
|
47
46
|
|
48
|
-
[
|
49
|
-
|
47
|
+
[
|
48
|
+
[:storext_jsonb_attributes, 'jsonb'],
|
49
|
+
# [:storext_hstore_attributes, 'hstore']
|
50
|
+
].each do |prop_name, prefix|
|
50
51
|
test "detects present #{prop_name}" do
|
51
|
-
reln = Post.where(prop_name => { "#{prefix}_zip_code"
|
52
|
+
reln = Post.where(prop_name => { "#{prefix}_zip_code" => '35124' })
|
52
53
|
# puts reln.to_sql
|
53
54
|
assert_equal 1, reln.count, reln.to_sql
|
54
55
|
end
|
55
56
|
|
56
57
|
test "#{prop_name} is composeable in one where" do
|
57
58
|
# get the first matching post
|
58
|
-
posts = Post.where(prop_name => { "#{prefix}_zip_code"
|
59
|
+
posts = Post.where(prop_name => { "#{prefix}_zip_code" => '90210' })
|
59
60
|
# compose with previous query with the id of first post
|
60
|
-
reln = Post.where(prop_name => { "#{prefix}_zip_code"
|
61
|
+
reln = Post.where(prop_name => { "#{prefix}_zip_code" => '90210' }, id: posts.first.id)
|
61
62
|
# puts reln.to_sql
|
62
63
|
assert_operator posts.count, :>, 1
|
63
64
|
assert_equal 1, reln.count, reln.to_sql
|
@@ -65,9 +66,9 @@ class SquintTest < ActiveSupport::TestCase
|
|
65
66
|
|
66
67
|
test "#{prop_name} is composeable in multiple wheres" do
|
67
68
|
# get the first matching post
|
68
|
-
posts = Post.where(prop_name => { "#{prefix}_zip_code"
|
69
|
+
posts = Post.where(prop_name => { "#{prefix}_zip_code" => '90210' })
|
69
70
|
# compose with previous query with the id of first post
|
70
|
-
reln = Post.where(prop_name => { "#{prefix}_zip_code"
|
71
|
+
reln = Post.where(prop_name => { "#{prefix}_zip_code" => '90210' }).where(id: posts.first.id)
|
71
72
|
# puts reln.to_sql
|
72
73
|
assert posts.count > 1
|
73
74
|
assert_equal 1, reln.count, reln.to_sql
|
@@ -76,39 +77,42 @@ class SquintTest < ActiveSupport::TestCase
|
|
76
77
|
|
77
78
|
[[:storext_jsonb_attributes, 'jsonb'],
|
78
79
|
[:storext_hstore_attributes, 'hstore']].each do |prop_name, prefix|
|
80
|
+
|
79
81
|
test "detects default #{prop_name}" do
|
80
|
-
reln = Post.where(prop_name => { "#{prefix}_zip_code"
|
82
|
+
reln = Post.where(prop_name => { "#{prefix}_zip_code" => '90210' })
|
81
83
|
# puts reln.to_sql
|
82
84
|
assert_equal Post.all.count - 6, reln.count, reln.to_sql
|
83
85
|
end
|
84
86
|
|
85
87
|
test "detects present integer #{prop_name}" do
|
86
|
-
reln = Post.where(prop_name => { "#{prefix}_friend_count"
|
88
|
+
reln = Post.where(prop_name => { "#{prefix}_friend_count" => 10 })
|
87
89
|
# puts reln.to_sql
|
88
90
|
assert_equal 1, reln.count, reln.to_sql
|
89
91
|
end
|
90
92
|
|
91
93
|
test "detects default integer #{prop_name}" do
|
92
|
-
reln = Post.where(prop_name => { "#{prefix}_friend_count"
|
94
|
+
reln = Post.where(prop_name => { "#{prefix}_friend_count" => 0 })
|
93
95
|
# puts reln.to_sql
|
94
96
|
assert_equal Post.all.count - 5, reln.count, reln.to_sql
|
95
97
|
end
|
96
98
|
|
97
99
|
test "detects default Falseclass #{prop_name}" do
|
98
|
-
reln = Post.where(prop_name => { "#{prefix}_is_awesome"
|
100
|
+
reln = Post.where(prop_name => { "#{prefix}_is_awesome" => false })
|
99
101
|
# puts reln.to_sql
|
100
102
|
assert_equal Post.all.count - 1, reln.count, reln.to_sql
|
101
103
|
end
|
102
104
|
end
|
105
|
+
|
103
106
|
test "handles string parameters" do
|
104
|
-
reln = Post.where(storext_jsonb_attributes: { "jsonb_friend_count"
|
107
|
+
reln = Post.where(storext_jsonb_attributes: { "jsonb_friend_count" => 11 }).
|
105
108
|
where("posts.title = ?", 'With Storext is aweesome not default title')
|
106
109
|
assert_nothing_raised do
|
107
110
|
assert_equal 1, reln.count
|
108
111
|
end
|
109
112
|
end
|
113
|
+
|
110
114
|
test "handles multiple non-hash parameters" do
|
111
|
-
reln = Post.where(storext_jsonb_attributes: { "jsonb_friend_count"
|
115
|
+
reln = Post.where(storext_jsonb_attributes: { "jsonb_friend_count" => 11 }).
|
112
116
|
where("posts.id between ? and ?",
|
113
117
|
posts(:with_storext_is_awesome_not_default).id,
|
114
118
|
posts(:with_storext_is_awesome_not_default).id + 1)
|
data/test/test_helper.rb
CHANGED
@@ -25,5 +25,9 @@ class ActiveSupport::TestCase
|
|
25
25
|
fixtures :all
|
26
26
|
# 'cuz I want to be able to login to the db and see things
|
27
27
|
# and there aren't many tests here anyway, so speed isn't a problem
|
28
|
-
|
28
|
+
if ActiveRecord::VERSION::STRING < '5'
|
29
|
+
self.use_transactional_fixtures = false
|
30
|
+
elsif ActiveRecord::VERSION::STRING > '5'
|
31
|
+
self.use_transactional_tests = false
|
32
|
+
end
|
29
33
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: squint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David H. Wilkins
|
@@ -9,20 +9,20 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-07-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: 4.2.8
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - "
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 4.2.8
|
28
28
|
- !ruby/object:Gem::Dependency
|
@@ -39,6 +39,20 @@ dependencies:
|
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: appraisal
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
42
56
|
description: Use rails semantics to search keys and values inside PostgreSQL jsonb,
|
43
57
|
json and hstore columns. Compatible with StoreXT attributes.
|
44
58
|
email:
|
@@ -48,10 +62,12 @@ executables: []
|
|
48
62
|
extensions: []
|
49
63
|
extra_rdoc_files: []
|
50
64
|
files:
|
65
|
+
- ".all-contributorsrc"
|
51
66
|
- MIT-LICENSE
|
52
67
|
- Rakefile
|
53
68
|
- lib/squint.rb
|
54
69
|
- lib/squint/version.rb
|
70
|
+
- readme.md
|
55
71
|
- test/dummy/Rakefile
|
56
72
|
- test/dummy/app/models/post.rb
|
57
73
|
- test/dummy/app/models/post.rb~
|
@@ -69,8 +85,8 @@ files:
|
|
69
85
|
- test/dummy/log/test.log
|
70
86
|
- test/dummy/test/fixtures/posts.yml
|
71
87
|
- test/dummy/test/fixtures/posts.yml~
|
72
|
-
- test/dummy/test/models/post_test.rb
|
73
88
|
- test/dummy/test/models/post_test.rb~
|
89
|
+
- test/reports/TEST-SquintTest.xml
|
74
90
|
- test/squint_test.rb
|
75
91
|
- test/test_helper.rb
|
76
92
|
- test/test_helper.rb~
|
@@ -94,16 +110,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
110
|
version: '0'
|
95
111
|
requirements: []
|
96
112
|
rubyforge_project:
|
97
|
-
rubygems_version: 2.6.
|
113
|
+
rubygems_version: 2.6.12
|
98
114
|
signing_key:
|
99
115
|
specification_version: 4
|
100
116
|
summary: Search PostgreSQL jsonb and hstore columns
|
101
117
|
test_files:
|
118
|
+
- test/reports/TEST-SquintTest.xml
|
102
119
|
- test/test_helper.rb
|
103
120
|
- test/dummy/Rakefile
|
104
121
|
- test/dummy/app/models/post.rb~
|
105
122
|
- test/dummy/app/models/post.rb
|
106
|
-
- test/dummy/test/models/post_test.rb
|
107
123
|
- test/dummy/test/models/post_test.rb~
|
108
124
|
- test/dummy/test/fixtures/posts.yml~
|
109
125
|
- test/dummy/test/fixtures/posts.yml
|