On Thu, Jul 15, 2021 at 4:29 AM Silviu Panaite <[email protected]>
wrote:
>
> 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?
>
This works fine in my environment:
DB.create_table(:tests) do
primary_key :id
Time :created_at
Time :updated_at
end
class Test < Sequel::Model
plugin :timestamps
plugin :prepared_statements
end
t = Test.new
t.save
Log:
$ ruby bin/sequel -E postgres:///?user=sequel_test t.rb
I, [2021-07-15T07:42:55.196032 #67844] INFO -- : (0.000613s) SET
standard_conforming_strings = ON
I, [2021-07-15T07:42:55.196466 #67844] INFO -- : (0.000127s) SET
client_min_messages = 'WARNING'
I, [2021-07-15T07:42:55.196695 #67844] INFO -- : (0.000150s) SET DateStyle
= 'ISO'
I, [2021-07-15T07:42:55.199196 #67844] INFO -- : (0.001387s) SELECT
CAST(current_setting('server_version_num') AS integer) AS v
I, [2021-07-15T07:42:55.212642 #67844] INFO -- : (0.012799s) CREATE TABLE
"tests" ("id" integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
"created_at" timestamp, "updated_at" timestamp)
I, [2021-07-15T07:42:55.237449 #67844] INFO -- : (0.020762s) SELECT
"pg_attribute"."attname" AS "name", CAST("pg_attribute"."atttypid" AS
integer) AS "oid", CAST("basetype"."oid" AS integer) AS "base_oid",
format_type("basetype"."oid", "pg_type"."typtypmod") AS "db_base_type",
format_type("pg_type"."oid", "pg_attribute"."atttypmod") AS "db_type",
pg_get_expr("pg_attrdef"."adbin", "pg_class"."oid") AS "default", NOT
"pg_attribute"."attnotnull" AS "allow_null",
COALESCE(("pg_attribute"."attnum" = ANY("pg_index"."indkey")), false) AS
"primary_key", "pg_attribute"."attidentity", ("pg_attribute"."attgenerated"
!= '') AS "generated" FROM "pg_class" INNER JOIN "pg_attribute" ON
("pg_attribute"."attrelid" = "pg_class"."oid") INNER JOIN "pg_type" ON
("pg_type"."oid" = "pg_attribute"."atttypid") LEFT OUTER JOIN "pg_type" AS
"basetype" ON ("basetype"."oid" = "pg_type"."typbasetype") LEFT OUTER JOIN
"pg_attrdef" ON (("pg_attrdef"."adrelid" = "pg_class"."oid") AND
("pg_attrdef"."adnum" = "pg_attribute"."attnum")) LEFT OUTER JOIN
"pg_index" ON (("pg_index"."indrelid" = "pg_class"."oid") AND
("pg_index"."indisprimary" IS TRUE)) WHERE (("pg_attribute"."attisdropped"
IS FALSE) AND ("pg_attribute"."attnum" > 0) AND ("pg_class"."oid" =
CAST(CAST('"tests"' AS regclass) AS oid))) ORDER BY "pg_attribute"."attnum"
I, [2021-07-15T07:42:55.251194 #67844] INFO -- : (0.000113s) BEGIN
I, [2021-07-15T07:42:55.254152 #67844] INFO -- : (0.001941s) PREPARE
smpsp_1 AS INSERT INTO "tests" ("created_at") VALUES ($1) RETURNING "id",
"created_at", "updated_at"
I, [2021-07-15T07:42:55.256876 #67844] INFO -- : (0.002613s) EXECUTE
smpsp_1 (INSERT INTO "tests" ("created_at") VALUES ($1) RETURNING "id",
"created_at", "updated_at"); ["'2021-07-15 07:42:55.250899-0700'"]
I, [2021-07-15T07:42:55.257792 #67844] INFO -- : (0.000379s) COMMIT
Note that we have specs for usage of Time types in prepared statements with
bound variables (spec/integration/prepared_statement_test.rb), and they
pass in all CI environments (currently GitHub Actions, previously Travis
CI). Additionally, timestamps and prepared_statements are two of the more
popular plugins, so if this was broken in general, it probably would have
been reported earlier. This leads me to conclude that the most likely
reason for the failure is an issue specific to your environment, and not a
general problem in Sequel. I couldn't rule out this being a problem with
Sequel, but the burden of proof is on you to show this is bug in Sequel and
not an issue specific to your environment.
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/CADGZSSczY9vUjzMufKGkX9_GvYZbL4LWhYD2hiVYw%2Bh4qNALVA%40mail.gmail.com.