The issue is that *plugin :timestamps* and *plugin :prepared_statements 
don't work together*
class Test < Sequel::Model
   plugin :timestamps
   plugin :prepared_statements
end
t = Test.new
t.save 
*/usr/local/lib/ruby/gems/3.0.0/gems/sequel-5.46.0/lib/sequel/adapters/postgres.rb:506:in
 
`exec_prepared': ERROR:  error in argument for $1: could not parse string 
"'2021-07-15 14:27:11.263364+0300'" as timestamp (PG::SyntaxError)*

also *db.freeze* will not work on the* :adapter=>"postgres" *

Should I add this in git as an issue?

Thank you,
Silviu
On Friday, 9 July 2021 at 18:11:17 UTC+3 Jeremy Evans wrote:

> On Fri, Jul 9, 2021 at 3:13 AM Silviu Panaite <[email protected]> 
> wrote:
>
>> Hi all,
>>
>> I am having issues with PG adapter and Sequel::Model.plugin 
>> :timestamps... when I try to save an db object I get:
>>
>> Sequel::DatabaseError (PG::SyntaxError: ERROR:  error in argument for $1: 
>> could not parse string "'2021-07-09 10:09:54.591896+0000'" as timestamptz)
>>
>> How would one debug such an issue?
>>
>
> This issue definitely comes from the database server's parsing, not 
> Sequel's parsing.  You can tell because it raises PG::SyntaxError.
>
> I can't reproduce this issue, either with or without bound variables:
>
> s = '2021-07-09 10:09:54.591896+0000'
> # => "2021-07-09 10:09:54.591896+0000"
> DB.get(Sequel.cast(s, :timestamptz))
> # SELECT CAST('2021-07-09 10:09:54.591896+0000' AS timestamptz) AS "v" 
> LIMIT 1
> => 2021-07-09 03:09:54.591896 -0700
> ps = DB.select(Sequel.cast(:$n, :timestamptz)).prepare(:single_value, 
> :get_tstz)
> ps.call(:n=>s)
> # PREPARE get_tstz AS SELECT CAST($1 AS timestamptz) LIMIT 1
> # EXECUTE get_tstz; ["2021-07-09 10:09:54.591896+0000"]
> => 2021-07-09 03:09:54.591896 -0700
>
> I also tried surrounding the timestamp value in single quotes, with the 
> same results.
>
> Can you put together a self contained example showing this problem?
>
> Thanks,
> Jeremy
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/c59a2ab6-aeee-448e-a49a-8aed003fe40fn%40googlegroups.com.

Reply via email to