On Wednesday, August 1, 2012 10:29:52 AM UTC-7, mhayden wrote: > > > Jeremy, > > Thanks for the quick analysis and response! That explains much. > > Do you think it is unusual that I could still get a DateTime from the DB > in some cases given my current setup? Following is some log output showing > remember_created_at is a DateTime after an update, although a > subsequent console session then shows it is a Time. Could this be from a > cached object in Sequel before the update? > > (0.000181s) BEGIN > (0.000307s) UPDATE `users` SET `reset_password_sent_at` = NULL, > `confirmed_at` = '2012-02-02 23:10:19', `last_sign_in_at` = '2012-07-26 > 18:43:22', `failed_attempts` = 0, `username` = NULL, `confirmation_sent_at` > = '2012-02-02 23:09:59', `current_sign_in_ip` = '71.141.115.223', > `encrypted_password` = > '$2a$10$w9CNjwxN9EoexQTfSnblhevM9717vofgMX0Xg5r3SmG0H1Zso3d0W', `email` = ' > [email protected]', `last_sign_in_ip` = '71.141.103.194', `updated_at` = > '2012-07-31 19:55:27', `remember_created_at` = '2012-07-31 19:55:27', > `unlock_token` = NULL, `sign_in_count` = 27, `reset_password_token` = NULL, > `confirmation_token` = NULL, `current_sign_in_at` = '2012-07-31 19:20:39', > `locked_at` = NULL, `created_at` = '2012-02-02 23:09:59' WHERE (`id` = 52) > LIMIT 1 > (0.000177s) COMMIT > ===========> custom remember_cookie_values resource.class: User > ===========> custom remember_cookie_values remember_expires_at.class: > DateTime >
That's probably the case. Sequel does not refresh values after update (only after insert), so if it was a DateTime instance before the update, it will be one after the update. You can manually call refresh after updating to retrieve new values from the database (which should give you Time values on mysql2). Note that some database drivers will give you Time instances in some cases and DateTime instances in other cases. I don't think mysql2 does that, but I haven't looked into it. Personally, I consider doing so a design flaw, since Time and DateTime have different APIs. Nice to see someone handling passwords correctly, though encrypted_password is probably a poor naming choice, since you are using hashing (a one-way function) and not encryption (a two-way function). 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/-/fkD9Pxmg5voJ. 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.
