porsager / postgres

Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare
The Unlicense
7.55k stars 274 forks source link

periods in string split string #987

Open bobbymannino opened 1 week ago

bobbymannino commented 1 week ago

if you have a string "bonobo.bob@bom.com" no matter how you insert it;

"sqlcall new_user(${email})" "sqlcall new_user(${sql(email)})"

I end up with the sql call new_user ("bonobo"."bob@bom"."com")

Why is this happening? im sure its me but I cant figure out why?

chiuwah commented 1 day ago

If you put the email in an object and then insert it in the sql request, it should work:

const user = { email: 'bonobo.bob@bom.com' }

await sql`insert into users ${ sql(user, 'email') }`