On Friday, August 3, 2012 8:26:09 AM UTC-7, blambeau wrote:
>
> Hi Jeremy,
>
> I'm not sure whether this is a bug, or if I use Sequel/SQlite in a strange
> way. Anyway, the code below shows the issue I'm encountering and the way
> I've found to fix it... Is there something I get wrong?
>
> require 'sequel'
> db = Sequel.sqlite
> db.use_timestamp_timezones=true # seen in another thread, does not change
> anything
>
This is the current default, so it shouldn't change anything. I am planning
to switch the default to false in the next major version, since I think
using timezones in timestamps does not work with the SQLite built-in
date/time functions.
db.create_table(:test){
> primary_key :id
> column :latest_change, "timestamp with time zone",
> :default=>"now()".lit, :null=>false
> }
> db[:test].insert(:latest_change => Time.now)
>
This is because "timestamp with time zone" is not recognized by Sequel's
sqlite adapter as a timestamp type, only "datetime" and "timestamp" are
recognized as such. SQLite doesn't support a native timestamp type, so I'm
not sure why you are choosing to use "timestamp with time zone". The
Sequel way to do what you want is:
db.create_table(:test){
primary_key :id
Time :latest_change, :default=>"now()".lit, :null=>false
}
> # Explicit proc resolves the problem for me:
> db.conversion_procs['timestamp with time zone'] =
> db.method(:to_application_timestamp)
> puts db[:test].first[:latest_change].class
> # => Time
>
If you really must use "timestamp with time zone" as your type, that's how
you are going to have to handle it. I am not adding support for other
timestamp type names to the sqlite adapter (what's next, "timestamp without
time zone"?).
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/sequel-talk/-/6KwGI8H2PEcJ.
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.