active_record_extended 0.2.1 → 0.3.0
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/.codeclimate.yml +0 -0
- data/.gitignore +0 -0
- data/.rspec +0 -0
- data/.rubocop.yml +0 -0
- data/.ruby-gemset +0 -0
- data/.ruby-version +0 -0
- data/.travis.yml +0 -0
- data/CHANGELOG.md +8 -0
- data/CODE_OF_CONDUCT.md +0 -0
- data/Gemfile +0 -0
- data/Gemfile.lock +1 -1
- data/LICENSE.txt +0 -0
- data/README.md +0 -0
- data/Rakefile +1 -1
- data/active_record_extended.gemspec +1 -1
- data/gemfiles/activerecord-51.gemfile +0 -0
- data/gemfiles/activerecord-52+.gemfile +0 -0
- data/gemfiles/activerecord-52.gemfile +0 -0
- data/lib/active_record_extended/active_record.rb +4 -4
- data/lib/active_record_extended/arel/nodes.rb +0 -0
- data/lib/active_record_extended/arel/predications.rb +0 -0
- data/lib/active_record_extended/arel/visitors/postgresql_decorator.rb +0 -6
- data/lib/active_record_extended/arel.rb +0 -0
- data/lib/active_record_extended/patch/5_1/where_clause.rb +0 -0
- data/lib/active_record_extended/patch/5_2/where_clause.rb +0 -0
- data/lib/active_record_extended/predicate_builder/array_handler_decorator.rb +0 -0
- data/lib/active_record_extended/query_methods/any_of.rb +0 -0
- data/lib/active_record_extended/query_methods/either.rb +0 -0
- data/lib/active_record_extended/query_methods/where_chain.rb +29 -0
- data/lib/active_record_extended/version.rb +1 -1
- data/lib/active_record_extended.rb +0 -0
- data/spec/active_record_extended_spec.rb +0 -0
- data/spec/query_methods/any_of_spec.rb +0 -0
- data/spec/query_methods/array_query_spec.rb +0 -0
- data/spec/query_methods/either_spec.rb +0 -0
- data/spec/query_methods/hash_query_spec.rb +0 -0
- data/spec/spec_helper.rb +1 -4
- data/spec/sql_inspections/any_of_sql_spec.rb +0 -0
- data/spec/sql_inspections/arel/array_spec.rb +0 -0
- data/spec/sql_inspections/contains_sql_queries_spec.rb +0 -0
- data/spec/sql_inspections/either_sql_spec.rb +0 -0
- data/spec/support/database_cleaner.rb +0 -0
- data/spec/support/models.rb +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: ea05f761dcce2d09ac0b86e315396e9f6bbc822d53df4bf085bc1b161a28904e
|
4
|
+
data.tar.gz: 42283db511f3ca78b5d6963c2d1cf642b1bbbf0f8c77416f37d56843e0c8a957
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 050ad5a8796e2886691b63723470d506002c62a53ed0c54b658678c257d9d60e6a50aab580bd189f207c30c28c6c53177a75411b73b03d3255b9f9b7cc4a2fb1
|
7
|
+
data.tar.gz: bddfdc0cc704d95e98785697a9b1b80e43b193ec97acc40ba12fa0663010b80e9b65437227c16b00f01a52ea3d63ef4d9b04686c4ad66b596d5c05eb8822e0a4
|
data/.codeclimate.yml
CHANGED
File without changes
|
data/.gitignore
CHANGED
File without changes
|
data/.rspec
CHANGED
File without changes
|
data/.rubocop.yml
CHANGED
File without changes
|
data/.ruby-gemset
CHANGED
File without changes
|
data/.ruby-version
CHANGED
File without changes
|
data/.travis.yml
CHANGED
File without changes
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# 0.3.0 - May 9th 2018
|
2
|
+
|
3
|
+
- Fixed ActiveRecord QueryMethod constant load error.
|
4
|
+
|
5
|
+
# 0.2.1 - May 6th 2018
|
6
|
+
|
7
|
+
Changed how where clause is required. This is to hopefully future proof the next minior update to ActiveRecord.
|
8
|
+
|
1
9
|
# 0.2.0 - May 6th 2018
|
2
10
|
|
3
11
|
Added ActiveRecord Where Chain Functionality
|
data/CODE_OF_CONDUCT.md
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/Gemfile.lock
CHANGED
data/LICENSE.txt
CHANGED
File without changes
|
data/README.md
CHANGED
File without changes
|
data/Rakefile
CHANGED
@@ -11,7 +11,7 @@ task :setup do
|
|
11
11
|
if File.exist?(".env")
|
12
12
|
puts "This will overwrite your existing .env file"
|
13
13
|
end
|
14
|
-
db_name = fetch_input("Enter your database name: [
|
14
|
+
db_name = fetch_input("Enter your database name: [active_record_extended_test] ")
|
15
15
|
db_user = fetch_input("Enter your database user: [] ")
|
16
16
|
db_password = fetch_input("Enter your database password: [] ")
|
17
17
|
db_server = fetch_input("Enter your database server: [localhost] ")
|
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
|
14
14
|
spec.summary = "Adds extended functionality to Activerecord Postgres implementation"
|
15
15
|
spec.description = "Adds extended functionality to Activerecord Postgres implementation"
|
16
|
-
spec.homepage = "https://github.com/georgekaraszi/
|
16
|
+
spec.homepage = "https://github.com/georgekaraszi/ActiveRecordExtended"
|
17
17
|
spec.license = "MIT"
|
18
18
|
|
19
19
|
spec.files = `git ls-files`.split("\n")
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "active_record"
|
4
|
+
require "active_record/relation"
|
5
|
+
require "active_record/relation/query_methods"
|
4
6
|
|
5
7
|
require "active_record_extended/predicate_builder/array_handler_decorator"
|
6
|
-
|
7
|
-
require "active_record_extended/query_methods/either"
|
8
|
-
require "active_record_extended/query_methods/any_of"
|
8
|
+
Dir["#{File.dirname(__FILE__)}/query_methods/**/*.rb"].each { |f| require File.expand_path(f) }
|
9
9
|
|
10
|
-
if ActiveRecord::VERSION::MAJOR
|
10
|
+
if ActiveRecord::VERSION::MAJOR == 5 && ActiveRecord::VERSION::MINOR == 1
|
11
11
|
require "active_record_extended/patch/5_1/where_clause"
|
12
12
|
elsif ActiveRecord::VERSION::MAJOR >= 5
|
13
13
|
require "active_record_extended/patch/5_2/where_clause"
|
File without changes
|
File without changes
|
@@ -55,12 +55,6 @@ module ActiveRecordExtended
|
|
55
55
|
infix_value object, collector, " >>= "
|
56
56
|
end
|
57
57
|
|
58
|
-
def visit_Arel_Nodes_AnyOf(object, collector)
|
59
|
-
pp object
|
60
|
-
pp collector
|
61
|
-
collector
|
62
|
-
end
|
63
|
-
|
64
58
|
def matchable_column?(col, object)
|
65
59
|
col.name == object.left.name.to_s || col.name == object.left.relation.name.to_s
|
66
60
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module ActiveRecordExtended
|
4
4
|
module WhereChain
|
5
|
+
# Finds Records that have an array column that contain any a set of values
|
6
|
+
# User.where.overlap(tags: [1,2])
|
7
|
+
# # SELECT * FROM users WHERE tags && {1,2}
|
5
8
|
def overlap(opts, *rest)
|
6
9
|
substitute_comparisons(opts, rest, Arel::Nodes::Overlap, "overlap")
|
7
10
|
end
|
@@ -18,14 +21,40 @@ module ActiveRecordExtended
|
|
18
21
|
substitute_comparisons(opts, rest, Arel::Nodes::ContainsEquals, "contains_or_equals")
|
19
22
|
end
|
20
23
|
|
24
|
+
# Finds Records that contain an element in an array column
|
25
|
+
# User.where.any(tags: 3)
|
26
|
+
# # SELECT user.* FROM user WHERE 3 = ANY(user.tags)
|
21
27
|
def any(opts, *rest)
|
22
28
|
equality_to_function("ANY", opts, rest)
|
23
29
|
end
|
24
30
|
|
31
|
+
# Finds Records that contain a single matchable array element
|
32
|
+
# User.where.all(tags: 3)
|
33
|
+
# # SELECT user.* FROM user WHERE 3 = ALL(user.tags)
|
25
34
|
def all(opts, *rest)
|
26
35
|
equality_to_function("ALL", opts, rest)
|
27
36
|
end
|
28
37
|
|
38
|
+
# Finds Records that contains a nested set elements
|
39
|
+
#
|
40
|
+
# Array Column Type:
|
41
|
+
# User.where.contains(tags: [1, 3])
|
42
|
+
# # SELECT user.* FROM user WHERE user.tags @> {1,3}
|
43
|
+
#
|
44
|
+
# HStore Column Type:
|
45
|
+
# User.where.contains(data: { nickname: 'chainer' })
|
46
|
+
# # SELECT user.* FROM user WHERE user.data @> 'nickname' => 'chainer'
|
47
|
+
#
|
48
|
+
# JSONB Column Type:
|
49
|
+
# User.where.contains(data: { nickname: 'chainer' })
|
50
|
+
# # SELECT user.* FROM user WHERE user.data @> {'nickname': 'chainer'}
|
51
|
+
#
|
52
|
+
# This can also be used along side joined tables
|
53
|
+
#
|
54
|
+
# JSONB Column Type Example:
|
55
|
+
# Tag.joins(:user).where.contains(user: { data: { nickname: 'chainer' } })
|
56
|
+
# # SELECT tags.* FROM tags INNER JOIN user on user.id = tags.user_id WHERE user.data @> { nickname: 'chainer' }
|
57
|
+
#
|
29
58
|
def contains(opts, *rest)
|
30
59
|
build_where_chain(opts, rest) do |arel|
|
31
60
|
case arel
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
3
|
+
require "active_record_extended"
|
4
4
|
|
5
5
|
unless ENV["DATABASE_URL"]
|
6
6
|
require "dotenv"
|
@@ -23,6 +23,3 @@ RSpec.configure do |config|
|
|
23
23
|
c.syntax = :expect
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
27
|
-
# Gem files must be loaded last
|
28
|
-
require "active_record_extended"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/support/models.rb
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_extended
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- George Protacio-Karaszi
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-05-
|
13
|
+
date: 2018-05-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -172,7 +172,7 @@ files:
|
|
172
172
|
- spec/sql_inspections/either_sql_spec.rb
|
173
173
|
- spec/support/database_cleaner.rb
|
174
174
|
- spec/support/models.rb
|
175
|
-
homepage: https://github.com/georgekaraszi/
|
175
|
+
homepage: https://github.com/georgekaraszi/ActiveRecordExtended
|
176
176
|
licenses:
|
177
177
|
- MIT
|
178
178
|
metadata: {}
|