pgtyped icon indicating copy to clipboard operation
pgtyped copied to clipboard

Avoid type inference for one parameter

Open danielbrauer opened this issue 5 years ago • 1 comments

I'm trying to use time stamp for keyset pagination, and running into problems with precision because it gets converted to a JS Date while in my code, and then back to the Postgres type in the next query. What would my best option be for passing the exact value of a time stamp out of a query, and then getting it into another query?

So far I've been trying to get it out as a string, with:

EXTRACT(EPOCH FROM posts.published)::text AS index and to_timestamp(cast(:pageIndex as double precision))

But:

  1. I can't seem to convince pgtyped that :pageIndex should be a string, and
  2. This doesn't feel like the best way of accomplishing what I want.

danielbrauer avatar Aug 18 '20 08:08 danielbrauer

I guess what I probably want is to be able to return the underlying int8 using something like this https://github.com/adelsz/pgtyped/issues/146

danielbrauer avatar Aug 18 '20 12:08 danielbrauer

Type conversion can now be controlled both at compile time and run time. Mapping timestamp to string should be a good fix.

adelsz avatar Jan 29 '23 01:01 adelsz