activerecord-like 2.1 → 2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d3e8f03f4997b7392648d80a676684f11c0cd081
4
- data.tar.gz: 34c1684aedf672fd501445eb3151bc6596c2bee8
3
+ metadata.gz: 9a5c0c2ab913d52c04984736a54d8a2cd2832ea9
4
+ data.tar.gz: 665673067501add2fff21343a6b73d2449ca2604
5
5
  SHA512:
6
- metadata.gz: 99f469e8b86a8af0505c295d1f4f9d838134bccd3cf010e4e6df1b7f42eb138fa19f002151f2883533514efd70f43c3af8dbb35f9d8a8a53b70f628e142ff8ef
7
- data.tar.gz: 609f7592e5eca2777fe448055bf401b4d07525e741f9d01f036751c4e9ccc00d83ad73e236bb25515d3933426d922b8bd5f78157924e9e18c86205e8e1625393
6
+ metadata.gz: e4cca0a25e3480c37a079bbb41c80e88b6bf06dc73f59fa56640fe6d1dec4ce1c147e6b79cca32db42a3f59f313ec4cac38297acf5d2a371809579bf035be369
7
+ data.tar.gz: 208c3fba7b26f6f59b5ea7b7cc82b409c0fc3baeb8aca2da51e017992f027e9087c5fea6dbae303c06ab8d81af7583ccd4db0f8cdd6b7bacd34b67925dc4738d
@@ -16,6 +16,7 @@ env:
16
16
  gemfile:
17
17
  - gemfiles/rails_5_0.gemfile
18
18
  - gemfiles/rails_5_1.gemfile
19
+ - gemfiles/rails_5_2.gemfile
19
20
  before_script:
20
21
  - psql -c 'create database activerecord_like_test' -U postgres
21
22
  - mysql -e 'create database activerecord_like_test'
data/Appraisals CHANGED
@@ -1,7 +1,5 @@
1
- appraise "rails_5_0" do
2
- gem "activerecord", "~> 5.0.0"
3
- end
4
-
5
- appraise "rails_5_1" do
6
- gem "activerecord", "~> 5.1.0"
1
+ ("5.0".."5.2").each do |version|
2
+ appraise "rails_#{version.tr('.', '_')}" do
3
+ gem "activerecord", "~> #{version}.0"
4
+ end
7
5
  end
data/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  An Active Record Plugin that allows chaining a more DSL-style 'like' or 'not-like' query to an ActiveRecord::Base#where. Requires Rails 5 or higher.
11
11
 
12
- This plugin has been salvaged from the stellar work done by @amatsuda and @claudiob, and updated to ActiveRecord 5 by @PikachuEXE. Most of the code was previously in Active Record master, but was subsequently removed due to, amongst other, scope creep.
12
+ This plugin has been salvaged from the stellar work done by @amatsuda and @claudiob, and updated to ActiveRecord 5 by @PikachuEXE and 5.2 by @robotdana. Most of the code was previously in Active Record master, but was subsequently removed due to, amongst other, scope creep (see discussion [here](https://github.com/rails/rails/commit/8d02afeaee8993bd0fde69687fdd9bf30921e805)).
13
13
  Array parameter handling was added by @rzane - thanks!
14
14
 
15
15
  ## Installation
@@ -4,4 +4,4 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "activerecord", "~> 5.0.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -4,4 +4,4 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "activerecord", "~> 5.1.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 5.2.0"
6
+
7
+ gemspec path: "../"
@@ -47,7 +47,11 @@ module ActiveRecord
47
47
  # Will lose the binding values since 5.1
48
48
  # due to this PR
49
49
  # https://github.com/rails/rails/pull/26073
50
- new_where_clause = Relation::WhereClause.new([new_predicate], equal_where_clause.binds)
50
+ new_where_clause = if equal_where_clause.respond_to?(:binds)
51
+ Relation::WhereClause.new([new_predicate], equal_where_clause.binds)
52
+ else
53
+ Relation::WhereClause.new([new_predicate])
54
+ end
51
55
 
52
56
  s.where_clause += new_where_clause
53
57
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Like
3
- VERSION = "2.1"
3
+ VERSION = "2.2"
4
4
  end
5
5
  end
@@ -13,9 +13,8 @@ describe ActiveRecord::QueryMethods::WhereChain do
13
13
  @attribute = "title"
14
14
  @value = '%value%'
15
15
 
16
- relation = Post.where.like(@attribute => @value)
17
- @first_predicate = relation.where_clause.send(:predicates).first
18
- @first_bind = relation.where_clause.send(:binds).first
16
+ @relation = Post.where.like(@attribute => @value)
17
+ @first_predicate = @relation.where_clause.send(:predicates).first
19
18
  end
20
19
 
21
20
  it "has the attribute as the left operand" do
@@ -23,7 +22,15 @@ describe ActiveRecord::QueryMethods::WhereChain do
23
22
  end
24
23
 
25
24
  it "has the value as the right operand" do
26
- @first_bind.value.must_equal @value
25
+ # Rails 5.0 & 5.1
26
+ first_bind = if @relation.where_clause.respond_to?(:binds)
27
+ @relation.where_clause.send(:binds).first
28
+ else
29
+ # Rails 5.2
30
+ @first_predicate.right.value
31
+ end
32
+
33
+ first_bind.value.must_equal @value
27
34
  end
28
35
  end
29
36
  end
@@ -13,9 +13,8 @@ describe ActiveRecord::QueryMethods::WhereChain do
13
13
  @attribute = "title"
14
14
  @value = '%value%'
15
15
 
16
- relation = Post.where.like(@attribute => @value)
17
- @first_predicate = relation.where_clause.send(:predicates).first
18
- @first_bind = relation.where_clause.send(:binds).first
16
+ @relation = Post.where.like(@attribute => @value)
17
+ @first_predicate = @relation.where_clause.send(:predicates).first
19
18
  end
20
19
 
21
20
  it "has the attribute as the left operand" do
@@ -23,7 +22,15 @@ describe ActiveRecord::QueryMethods::WhereChain do
23
22
  end
24
23
 
25
24
  it "has the value as the right operand" do
26
- @first_bind.value.must_equal @value
25
+ # Rails 5.0 & 5.1
26
+ first_bind = if @relation.where_clause.respond_to?(:binds)
27
+ @relation.where_clause.send(:binds).first
28
+ else
29
+ # Rails 5.2
30
+ @first_predicate.right.value
31
+ end
32
+
33
+ first_bind.value.must_equal @value
27
34
  end
28
35
  end
29
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-like
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.1'
4
+ version: '2.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - René van den Berg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-02 00:00:00.000000000 Z
11
+ date: 2018-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -126,6 +126,7 @@ files:
126
126
  - activerecord-like.gemspec
127
127
  - gemfiles/rails_5_0.gemfile
128
128
  - gemfiles/rails_5_1.gemfile
129
+ - gemfiles/rails_5_2.gemfile
129
130
  - lib/active_record/like.rb
130
131
  - lib/active_record/like/version.rb
131
132
  - lib/activerecord-like.rb