On Oct 18, 8:10 am, Will Gorman <[email protected]> wrote:
> Looks like there've been some improvements around type conversions for
> Oracle DATE columns when using JDBC. Yesterday I happened to run into the
> issue mentioned in this stackoverflow
> post<http://stackoverflow.com/questions/6138542/how-do-i-convert-a-jdbcora...>(while
> using 3.28).
> After switching to the master branch, I found that it now preserved the time
> component when using a Time or DateTime to set the value of a Model
> attribute backed by a DATE column (instead of setting it to midnight).
> However,
> although the time now makes it into the database I don't seem to be able to
> access it again from Sequel. That attribute of the model object returns a
> Date. For example:
>
> m = ModelSubclass.create do |x|
> x.date_field = DateTime.now
> puts x.date_field #class is Time
> end
>
> puts m.date_field #class is Date
I can't replicate this. I get a Time object:
DB.create_table(:foo){Date :f}
# CREATE TABLE "FOO" ("F" date)
# => nil
DB[:foo].insert(DateTime.now)
# INSERT INTO "FOO" VALUES (TIMESTAMP '2011-10-18 08:54:18.581000
-07:00')
# => nil
DB.schema(:foo)
# SELECT * FROM (SELECT sys_context('USERENV', 'CURRENT_USER') FROM
"DUAL") "T1" WHERE (ROWNUM <= 1)
# => [[:f,
{:type=>:datetime, :db_type=>"DATE", :default=>nil, :allow_null=>true,
:primary_key=>false, :column_size=>7, :scale=>nil, :ruby_default=>nil}]]
class Foo < Sequel::Model(:foo); end
f = Foo.create do |x|
x.f = DateTime.now
end
# Transaction.begin
# INSERT INTO "FOO" ("F") VALUES (TIMESTAMP '2011-10-18
08:55:58.000000 -07:00')
# Transaction.commit
# => #<Foo @values={:f=>Tue Oct 18 08:55:58 -0700 2011}>
f.f
# => Tue Oct 18 08:55:58 -0700 2011
class SubFoo < Foo; end
f = SubFoo.create do |x|
x.f = DateTime.now
end
# Transaction.begin
# INSERT INTO "FOO" ("F") VALUES (TIMESTAMP '2011-10-18
08:56:40.000000 -07:00')
# Transaction.commit
# => #<SubFoo @values={:f=>Tue Oct 18 08:56:40 -0700 2011}>
f.f
# => Tue Oct 18 08:56:40 -0700 2011
If you could submit a self contained example displaying the bug, I'll
definitely try to fix it.
Thanks,
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.