squeel 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.0.4 (2012-06-07)
2
+
3
+ * Fix regression in merge causing issues with scopes returning nil
4
+
1
5
  ## 1.0.3 (2012-06-07)
2
6
 
3
7
  * Port fix for Rails CVE-2012-2661 to Squeel.
@@ -40,7 +40,7 @@ module Squeel
40
40
  # the relations we're merging, and then use the default AR merge
41
41
  # code on the result.
42
42
  def merge(r, relations_visited = false)
43
- if relations_visited
43
+ if relations_visited or not ::ActiveRecord::Relation === r
44
44
  super(r)
45
45
  else
46
46
  clone.visit!.merge(r.clone.visit!, true)
@@ -40,7 +40,7 @@ module Squeel
40
40
  # the relations we're merging, and then use the default AR merge
41
41
  # code on the result.
42
42
  def merge(r, relations_visited = false)
43
- if relations_visited
43
+ if relations_visited or not ::ActiveRecord::Relation === r
44
44
  super(r)
45
45
  else
46
46
  clone.visit!.merge(r.clone.visit!, true)
@@ -1,3 +1,3 @@
1
1
  module Squeel
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
@@ -681,6 +681,11 @@ module Squeel
681
681
  sql.should match /Bert/
682
682
  end
683
683
 
684
+ it "doesn't ruin everything when a scope returns nil" do
685
+ relation = Person.nil_scope
686
+ relation.should eq Person.scoped
687
+ end
688
+
684
689
  end
685
690
 
686
691
  describe '#to_a' do
@@ -21,6 +21,8 @@ class Person < ActiveRecord::Base
21
21
  has_many :outgoing_messages, :class_name => 'Message', :foreign_key => :author_id
22
22
  has_many :incoming_messages, :class_name => 'Message', :foreign_key => :recipient_id
23
23
 
24
+ scope :nil_scope, lambda { nil }
25
+
24
26
  sifter :name_starts_or_ends_with do |value|
25
27
  (name =~ "#{value}%") | (name =~ "%#{value}")
26
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squeel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-07 00:00:00.000000000 Z
12
+ date: 2012-06-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -240,7 +240,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
240
240
  version: '0'
241
241
  segments:
242
242
  - 0
243
- hash: -3464922984987800394
243
+ hash: 4164570062879011051
244
244
  required_rubygems_version: !ruby/object:Gem::Requirement
245
245
  none: false
246
246
  requirements:
@@ -249,7 +249,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
249
249
  version: '0'
250
250
  segments:
251
251
  - 0
252
- hash: -3464922984987800394
252
+ hash: 4164570062879011051
253
253
  requirements: []
254
254
  rubyforge_project: squeel
255
255
  rubygems_version: 1.8.24