squeel 1.0.5 → 1.0.6

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.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.0.6 (2012-06-16)
2
+
3
+ * Prevent cloned KeyPaths from modifying each other. Fixes #135
4
+
1
5
  ## 1.0.5 (2012-06-08)
2
6
 
3
7
  * Stop visiting group_values on merge. AR hates ARel attributes in
data/Gemfile CHANGED
@@ -4,7 +4,7 @@ gemspec
4
4
  gem 'rake'
5
5
 
6
6
  rails = ENV['RAILS'] || '3-2-stable'
7
- arel = ENV['AREL'] || 'master'
7
+ arel = ENV['AREL'] || '3-0-stable'
8
8
 
9
9
  arel_opts = case arel
10
10
  when /\// # A path
@@ -200,6 +200,13 @@ module Squeel
200
200
 
201
201
  private
202
202
 
203
+ # Prevent a cloned keypath from inadvertently modifying the
204
+ # path of its source.
205
+ def initialize_copy(orig)
206
+ super
207
+ @path = @path.dup
208
+ end
209
+
203
210
  # Raises a NoMethodError manually, bypassing #method_missing.
204
211
  # Used by special-case operator overrides.
205
212
  def no_method_error(method_id)
@@ -1,3 +1,3 @@
1
1
  module Squeel
2
- VERSION = "1.0.5"
2
+ VERSION = "1.0.6"
3
3
  end
@@ -258,6 +258,14 @@ module Squeel
258
258
  block.debug_sql.should eq standard.debug_sql
259
259
  end
260
260
 
261
+ it 'eager loads belongs_to_associations' do
262
+ relation = Article.includes(:person).
263
+ where{person.name == 'Ernie'}
264
+ sql = relation.debug_sql
265
+ sql.should match /LEFT OUTER JOIN "people"/
266
+ sql.should match /"people"."name" = 'Ernie'/
267
+ end
268
+
261
269
  it 'eager loads polymorphic belongs_to associations' do
262
270
  relation = Note.includes{notable(Article)}.where{{notable(Article) => {title => 'hey'}}}
263
271
  relation.debug_sql.should match /"notes"."notable_type" = 'Article'/
@@ -106,6 +106,14 @@ module Squeel
106
106
  expect {-@k.third.fourth}.to raise_error NoMethodError
107
107
  end
108
108
 
109
+ it 'dups its path when it is duped' do
110
+ k1 = KeyPath.new([:one, :two])
111
+ k2 = k1.dup
112
+ k2.three
113
+ k2.path.should have(3).items
114
+ k1.path.should have(2).items
115
+ end
116
+
109
117
  end
110
118
  end
111
119
  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.5
4
+ version: 1.0.6
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-08 00:00:00.000000000 Z
12
+ date: 2012-06-16 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: -4324622899470909075
243
+ hash: -4410929732049188226
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: -4324622899470909075
252
+ hash: -4410929732049188226
253
253
  requirements: []
254
254
  rubyforge_project: squeel
255
255
  rubygems_version: 1.8.24