
Model.get(nil) returns an object instead of nil
Reported by Piotr Usewicz | October 16th, 2008 @ 07:20 AM
>> Operator.fixture {{ :name => '123', :code => 'xu' }}
=> [#<Proc:0x02775824@(irb):1>]
>> Operator.gen
~ INSERT INTO `operators` (`use_sms_billing`, `created_at`, `name`, `updated_at`, `code`) VALUES (FALSE, '2008-10-16 13:09:54', '123', '2008-10-16 13:09:54', 'xu')
>> Operator.get nil
~ SELECT `id`, `name`, `code`, `use_sms_billing`, `created_at`, `updated_at` FROM `operators` WHERE (`id` IS NULL) ORDER BY `id` LIMIT 1
=> #<Operator id=13 name="123" code="xu" use_sms_billing=false created_at=#<DateTime: 3927609611/1600,1/24,2299161> updated_at=#<DateTime: 3927609611/1600,1/24,2299161>>
After second invocation of Operator.get(nil), nil is returned properly.
Comments and changes to this ticket
-
Dan Kubb (dkubb) November 30th, 2008 @ 12:24 PM
- Assigned user changed from Sam Smoot to Dan Kubb (dkubb)
- State changed from new to open
I am going to take this on and make sure dkubb/dm-core has this behavior. I believe Model#get with nil should short-circuit, bypass any of the key typecasting it does and return nil.
-
Dan Kubb (dkubb) December 1st, 2008 @ 05:10 PM
- State changed from open to resolved
This should be resolved by the following commit to dkubb/dm-core:
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »