On 21 January 2012 16:40, Jeremy Evans <[email protected]> wrote: > > > If you are using bin/sequel to migrate, you would just put that code > in some file, and use the -I and/or -r flags to bin/sequel to load it > (in addition to the -m/-M to migrate). > > In terms of where to place it, if you are only going to be using it in > migrations, a class method should be fine. >
Thanks, I'll do that. > My bigger question is why Sequel::CURRENT_TIMESTAMP doesn't work > correctly for you on SQLite. The current Sequel code does this: > > datetime(CURRENT_TIMESTAMP, 'localtime') > > Is 'now' different than CURRENT_TIMESTAMP there? > > Jeremy > > About while back I asked about default timestamps with Sqlite3 on here and your advice was to use a .lit string, but I admit I haven't tried the CURRENT_TIMESTAMP since. http://osdir.com/ml/sequel-talk/2011-08/msg00016.html I just gave it a try, but it gave me this error: Error: Sequel::DatabaseError: SQLite3::SQLException: near "(": syntax error/Volumes/RubyProjects/Midas/vendor/ruby/1.9.1/gems/sqlite3-1.3.5/lib/sqlite3/database.rb:91:in `initialize' I checked the syntax of my migration and tried a couple of variations of the line to make sure it wasn't me: DateTime :last_login, null: false, default: Sequel::CURRENT_TIMESTAMP It doesn't work for Sqlite, but when using my helper it works with a postgres database on heroku. Line 91 in my sqlite3 gem looks fairly inocuous: # Returns a Statement object representing the given SQL. This does not # execute the statement; it merely prepares the statement for execution. # # The Statement can then be executed using Statement#execute. # def prepare sql stmt = SQLite3::Statement.new( self, sql ) # << Line 91 return stmt unless block_given? begin yield stmt ensure stmt.close end end I also tried replacing the line from the Sequel constant with the line I currently use: "(datetime('now','localtime'))" to "date(CURRENT_TIMESTAMP, 'localtime')" but it threw the same error. I just tried this, however, and it works: "(date(CURRENT_TIMESTAMP, 'localtime'))" The extra parens fix it. I'm not sure whether that's down to my system or Sqlite. My Sqlite gem is v1.3.5 and Sqlite3 is 3.7.9. Sequel is at 3.31.0. Regards, Iain -- 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.
