Hmm, it appears to have no connection to the prepared statements plugin,
but might be related to my version of Derby (10.8.2.2), which I
unfortunately cannot update...
ruby-1.6.5.1 :016 > DB.create_table(:a) {Time :a}
> [09:46:46] DEBUG [MDM.Dev] - (0.025000s) CREATE TABLE "A" ("A" timestamp)
> => nil
> jruby-1.6.5.1 :017 > t = Time.now
> => 2012-07-12 09:46:59 -0700
> jruby-1.6.5.1 :018 > t.to_f
> => 1342111619.922
> jruby-1.6.5.1 :019 > DB[:a].call(:insert, {:t => t}, :$t)
> [09:47:39] DEBUG [MDM.Dev] - (0.005000s) PREPARE INSERT INTO "A" VALUES (?)
> [09:47:39] DEBUG [MDM.Dev] - (0.003000s) EXECUTE; [2012-07-12 09:46:59
> -0700]
> [09:47:39] DEBUG [MDM.Dev] - (0.001000s) SELECT IDENTITY_VAL_LOCAL() FROM
> sysibm.sysdummy1
> => 30
> jruby-1.6.5.1 :020 > DB[:a].get(:a).to_f
> [09:48:10] DEBUG [MDM.Dev] - (0.003000s) SELECT "A" FROM "A" FETCH FIRST 1
> ROWS ONLY
> => 1342111619.0
On Thursday, July 12, 2012 9:26:32 AM UTC-7, Jeremy Evans wrote:
>
> On Thursday, July 12, 2012 8:47:08 AM UTC-7, Jeremy Evans wrote:
>>
>> On Thursday, July 12, 2012 4:01:43 AM UTC-7, Matt Hauck wrote:
>>>
>>> After turning on the prepared statements plugin, I have noticed that my
>>> timestamps are being truncated of their milliseconds when they are saved to
>>> the database (derby), resulting in a loss of accuracy of data that is
>>> rather unfortunate. Is this a known issue? Is there a workaround? Perhaps
>>> to disable prepared statements on these columns?
>>
>>
>> This is going to be an adapter specific issue. The postgres adapter has
>> specific code to keep the fractional seconds, but not all adapters do.
>>
>> Since you are using derby, this is going to be a jdbc adapter issue. The
>> jdbc adapter has code that is supposed to handle the fractional parts (see
>> set_ps_arg, java_sql_datetime, java_sql_timestamp in
>> lib/sequel/adapters/jdbc.rb). Please post the code you are using and an
>> SQL log.
>>
>> Disabling prepared statements may work around the issue.
>>
>> Thanks,
>> Jeremy
>>
>
> I can't replicate this issue:
>
> L:\sequel>jruby -rderby.jar -I lib bin\sequel -E
> "jdbc:derby:memory:myDb;create=true"
> Your database is stored in DB...
> irb(main):001:0> DB.create_table(:a){Time :a}
> I, [2012-07-12T09:16:25.661000 #3096] INFO -- : (0.188000s) CREATE TABLE
> "A" ("A" timestamp)
> => nil
> irb(main):002:0> t = Time.now
> => Thu Jul 12 09:16:25 -0700 2012
> irb(main):003:0> DB[:a].call(:insert, {:t=>t}, :$t)
> I, [2012-07-12T09:16:26.005000 #3096] INFO -- : (0.188000s) PREPARE
> INSERT INTO "A" VALUES (?)
> I, [2012-07-12T09:16:26.036000 #3096] INFO -- : (0.016000s) EXECUTE; [Thu
> Jul 12 09:16:25 -0700 2012]
> I, [2012-07-12T09:16:26.083000 #3096] INFO -- : (0.047000s) SELECT
> IDENTITY_VAL_LOCAL() FROM sysibm.sysdummy1
> => 0
> irb(main):004:0> DB[:a].get(:a).to_f
> I, [2012-07-12T09:16:27.895000 #3096] INFO -- : (0.015000s) SELECT "A"
> FROM "A" FETCH FIRST 1 ROWS ONLY
> => 1342109785.676
> irb(main):005:0> class A < Sequel::Model(:a)
> irb(main):006:1> plugin :prepared_statements
> irb(main):007:1> end
> => nil
> irb(main):008:0> A.delete
> I, [2012-07-12T09:19:01.103000 #3096] INFO -- : (0.015000s) DELETE FROM
> "A"
> => 1
> irb(main):009:0> A.create(:a=>t).a.to_f
> I, [2012-07-12T09:19:25.151000 #3096] INFO -- : (0.000000s)
> Transaction.begin
> I, [2012-07-12T09:19:25.151000 #3096] INFO -- : (0.000000s) PREPARE
> smpsp_1: INSERT INTO "A" ("A") VALUES (?)
> I, [2012-07-12T09:19:25.151000 #3096] INFO -- : (0.000000s) EXECUTE
> smpsp_1 (INSERT INTO "A" ("A") VALUES (?)); [Thu Jul 12 09:16:25 -0700 2012]
> I, [2012-07-12T09:19:25.151000 #3096] INFO -- : (0.000000s) SELECT
> IDENTITY_VAL_LOCAL() FROM sysibm.sysdummy1
> I, [2012-07-12T09:19:25.167000 #3096] INFO -- : (0.000000s)
> Transaction.commit
> => 1342109785.676
>
> Note in both the regular insert with bound variable and the model
> prepared_statements plugin usage in the model, there are fractional seconds
> on the retrieved value.
>
> 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/-/Aito96c_1qsJ.
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.