-
in my postgres database user.id type is uuid; but when I try TS string type to filter it results in an error. Am I doing something wrong? const getUser = (id: string) => {
const users = sql<
{
id: string;
created_at: Date;
name: string | null;
}[]
>`SELECT * FROM users WHERE id = '${id}'`; // Invalid Query: invalid input syntax for type uuid: "$1::text"
}; this error disappeared when I cast the id to text, but it's not really a solution: const getUser = (id: string) => {
const users = sql<
{
id: text; // Cannot find name 'text'. Did you mean 'Text'?
created_at: Date;
name: string | null;
}[]
>`SELECT * FROM users WHERE id::text = '${id}'`;
}; |
Beta Was this translation helpful? Give feedback.
Answered by
Newbie012
Oct 16, 2022
Replies: 1 comment 6 replies
-
What about this?
Another solution (it's not currently implemented) is to define a type called |
Beta Was this translation helpful? Give feedback.
6 replies
Answer selected by
mzalevski
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What about this?
Another solution (it's not currently implemented) is to define a type called
UUID
so SafeQL will know to cast it touuid
rather than atext
.