squeel 1.0.7 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ .rvmrc
@@ -1,3 +1,8 @@
1
+ ## 1.0.8 (2012-07-28)
2
+
3
+ * Fix an issue with properly casting values to column type when used
4
+ on Rails 3.0.x.
5
+
1
6
  ## 1.0.7 (2012-07-14)
2
7
 
3
8
  * Prevent reorder(nil) on reversed SQL from adding an order by id.
@@ -10,7 +10,11 @@ module Arel
10
10
  alias :table_name :name
11
11
 
12
12
  def [] name
13
- ::Arel::Attribute.new self, name.to_sym
13
+ if table_exists?
14
+ columns.find { |column| column.name == name.to_sym }
15
+ else
16
+ ::Arel::Attribute.new self, name.to_sym
17
+ end
14
18
  end
15
19
  end
16
20
 
@@ -1,3 +1,3 @@
1
1
  module Squeel
2
- VERSION = "1.0.7"
2
+ VERSION = "1.0.8"
3
3
  end
@@ -45,6 +45,22 @@ module Squeel
45
45
 
46
46
  end
47
47
 
48
+ describe 'finding by attribute' do
49
+
50
+ it 'returns nil when passed an empty string' do
51
+ Person.find_by_id('').should be_nil
52
+ end
53
+
54
+ it 'casts an empty string to the proper value' do
55
+ queries = queries_for do
56
+ Person.find_by_id('')
57
+ end
58
+ queries.should have(1).query
59
+ queries.first.should match /"people"."id" = 0/
60
+ end
61
+
62
+ end
63
+
48
64
  describe '#build_arel' do
49
65
 
50
66
  it 'joins associations' do
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.7
4
+ version: 1.0.8
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-07-14 00:00:00.000000000 Z
12
+ date: 2012-07-29 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: -1051407331683440462
243
+ hash: 2726279138342504508
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: -1051407331683440462
252
+ hash: 2726279138342504508
253
253
  requirements: []
254
254
  rubyforge_project: squeel
255
255
  rubygems_version: 1.8.24