I simplified the test to...
@db[:profiles].each do |r|
puts r[:email] + ", " + r[:experience] + ", " + r[:created_at]
end
I'm not even looking at the dob field which is a date and NULL, and I
get this...
F, [2008-06-30T12:51:51.344626 #22762] FATAL -- : Invalid date value
'' (invalid date) (Sequel::Error::InvalidValue)
/usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
core_ext.rb:159:in `to_date'
/usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
adapters/postgres.rb:172
/usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
adapters/postgres.rb:528:in `call'
/usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
adapters/postgres.rb:528:in `fetch_rows'
/usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
adapters/postgres.rb:524:in `each'
/usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
adapters/postgres.rb:524:in `fetch_rows'
/usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
adapters/postgres.rb:522:in `each'
/usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
adapters/postgres.rb:522:in `fetch_rows'
/usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
adapters/postgres.rb:60:in `[]'
/usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
adapters/postgres.rb:60:in `execute'
/usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
adapters/postgres.rb:229:in `execute'
/usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
connection_pool.rb:90:in `hold'
/usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
adapters/postgres.rb:229:in `execute'
/usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
adapters/postgres.rb:521:in `fetch_rows'
/usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
dataset.rb:231:in `each'
sequel_date_bug.rb:19:in `check'
sequel_date_bug.rb:78:in `run'
/usr/local/lib/ruby/gems/1.8/gems/main-2.8.0/lib/main/base.rb:25:in
`call'
/usr/local/lib/ruby/gems/1.8/gems/main-2.8.0/lib/main/base.rb:25:in
`run'
/usr/local/lib/ruby/gems/1.8/gems/main-2.8.0/lib/main/base.rb:13:in
`catch'
/usr/local/lib/ruby/gems/1.8/gems/main-2.8.0/lib/main/base.rb:13:in
`run'
/usr/local/lib/ruby/gems/1.8/gems/main-2.8.0/lib/main/factories.rb:
11:in `run'
/usr/local/lib/ruby/gems/1.8/gems/main-2.8.0/lib/main/factories.rb:
16:in `Main'
sequel_date_bug.rb:27
On Jun 30, 12:17 pm, Jim Morris <[EMAIL PROTECTED]> wrote:
> Hi, thanks for looking at this.
>
> The error comes from sequel not my code here is the stack dump...
>
> I, [2008-06-30T12:12:17.899823 #22006] INFO -- : SELECT "username",
> "users"."email", "last_ip", "password", "experience",
> "users"."created_at", "disabled", "profiles"."dob" FROM "users" INNER
> JOIN "profiles" ON ("profiles"."user_id" = "users"."id") WHERE
> ("referrer" = 2)
> I, [2008-06-30T12:12:17.901634 #22006] INFO -- : Invalid date value
> '' (invalid date)
> I, [2008-06-30T12:12:17.901708 #22006] INFO -- : Invalid date value
> '' (invalid date)
> F, [2008-06-30T12:12:17.901790 #22006] FATAL -- : Invalid date value
> '' (invalid date) (Sequel::Error::InvalidValue)
> /usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
> core_ext.rb:159:in `to_date'
> /usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
> adapters/postgres.rb:172
> /usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
> adapters/postgres.rb:528:in `call'
> /usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
> adapters/postgres.rb:528:in `fetch_rows'
> /usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
> adapters/postgres.rb:524:in `each'
> /usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
> adapters/postgres.rb:524:in `fetch_rows'
> /usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
> adapters/postgres.rb:522:in `each'
> /usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
> adapters/postgres.rb:522:in `fetch_rows'
> /usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
> adapters/postgres.rb:60:in `[]'
> /usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
> adapters/postgres.rb:60:in `execute'
> /usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
> adapters/postgres.rb:229:in `execute'
> /usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
> connection_pool.rb:83:in `hold'
> /usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
> adapters/postgres.rb:229:in `execute'
> /usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
> adapters/postgres.rb:521:in `fetch_rows'
> /usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
> dataset.rb:231:in `each'
> check_referrals.rb:29:in `check'
> /usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
> dataset.rb:234:in `each'
> /usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
> adapters/postgres.rb:533:in `fetch_rows'
> /usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
> adapters/postgres.rb:522:in `each'
> /usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
> adapters/postgres.rb:522:in `fetch_rows'
> /usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
> adapters/postgres.rb:60:in `[]'
> /usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
> adapters/postgres.rb:60:in `execute'
> /usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
> adapters/postgres.rb:229:in `execute'
> /usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
> connection_pool.rb:90:in `hold'
> /usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
> adapters/postgres.rb:229:in `execute'
> /usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
> adapters/postgres.rb:521:in `fetch_rows'
> /usr/local/lib/ruby/gems/1.8/gems/sequel_core-2.1.0/lib/sequel_core/
> dataset.rb:231:in `each'
> check_referrals.rb:23:in `check'
> check_referrals.rb:89:in `run'
> /usr/local/lib/ruby/gems/1.8/gems/main-2.8.0/lib/main/base.rb:25:in
> `call'
> /usr/local/lib/ruby/gems/1.8/gems/main-2.8.0/lib/main/base.rb:25:in
> `run'
> /usr/local/lib/ruby/gems/1.8/gems/main-2.8.0/lib/main/base.rb:13:in
> `catch'
> /usr/local/lib/ruby/gems/1.8/gems/main-2.8.0/lib/main/base.rb:13:in
> `run'
> /usr/local/lib/ruby/gems/1.8/gems/main-2.8.0/lib/main/factories.rb:
> 11:in `run'
> /usr/local/lib/ruby/gems/1.8/gems/main-2.8.0/lib/main/factories.rb:
> 16:in `Main'
> check_referrals.rb:38
>
> The database column is a date field, and may be null.
>
> The fetch I do is..
>
> @users.join(:profiles, :user_id => :id).filter(:referrer =>
> userid).select(:username, :users__email, :last_ip, :password, :experience,
> :users__created_at, :disabled, :profiles__dob).each
>
> The field that is null and causes the error is :profiles__dob, if I
> leave that out, or set all dob fields to something then I don't get
> the error.
>
> I looked at the relevant sequel code, and for some reason it is
> passing a nil value onto the date conversion, but that does not make a
> lot of sense as it seems to check for nil.
>
> Thanks
> Jim
>
> On Jun 30, 7:43 am, Jeremy Evans <[EMAIL PROTECTED]> wrote:
>
> > On Jun 29, 1:23 pm, Jim Morris <[EMAIL PROTECTED]> wrote:
>
> > > I just upgraded to 2.1.0, I'm using posgresql and my script that was
> > > working now throws a
>
> > > Invalid date value '' (invalid date) (Sequel::Error::InvalidValue)
>
> > > when it reads a date from the database that is NULL.
> > > It did not used to do this, and having NULL dates in the database is
> > > very much an OK thing.
>
> > > Any work arounds?
>
> > The adapter type conversion code converts NULLs to nil. Apparantly,
> > your code does something like nil.to_s.to_date, which would lead to
> > the error you describe. Without seeing your code, I can't tell you
> > how to fix it. My guess is that you upgraded from version 1.5.1 or
> > previous, and the model typecasting code introduced in 2.0.0 is now
> > giving you an error, but that's just a guess. Please pastie your code
> > somewhere with a full traceback if you would like me to look into it.
>
> > Jeremy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---