From 3d4dde4af15668d7073dadb10187d89cf682ed2c Mon Sep 17 00:00:00 2001 From: Merlin Diavova Date: Sun, 8 May 2022 12:37:46 +0000 Subject: [PATCH] pg: resolve PG string datetime values to V time.Time ones (#14336) Co-authored-by: Merlin Diavova --- vlib/pg/orm.v | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vlib/pg/orm.v b/vlib/pg/orm.v index ed0b1b4426..31f9617847 100644 --- a/vlib/pg/orm.v +++ b/vlib/pg/orm.v @@ -266,6 +266,11 @@ fn str_to_primitive(str string, typ int) ?orm.Primitive { return orm.Primitive(str) } orm.time { + if str.contains_any(' /:-') { + date_time_str := time.parse(str) ? + return orm.Primitive(date_time_str) + } + timestamp := str.int() return orm.Primitive(time.unix(timestamp)) }