Open Seidko opened 8 months ago
Hello! For some reason. I need to use . in my column name, but I found a problem. This is my code:
.
import postgres from 'postgres' const sql = postgres({ /* options */ }) // table has "meta.a" column const data = { 'meta.a': 'text' } await sql`INSERT INTO ${this.sql('object')} ${data} RETURNING *` // throw error `PostgresError: column "meta" of relation "object" does not exist`
It is weird. PostgreSQL supports using . in column name. I read the code and found this: https://github.com/porsager/postgres/blob/61c4d5b1d840ed1e3e0f8e84556544a33ee04149/src/types.js#L216-L218 It seems like these code replace all . to ".", this doesn't look like a correct behavior.
"."
"meta.a" should remain as-is. meta.a should be escaped to "meta"."a"
"meta.a"
meta.a
"meta"."a"
description
Hello! For some reason. I need to use
.
in my column name, but I found a problem. This is my code:It is weird. PostgreSQL supports using
.
in column name. I read the code and found this: https://github.com/porsager/postgres/blob/61c4d5b1d840ed1e3e0f8e84556544a33ee04149/src/types.js#L216-L218 It seems like these code replace all.
to"."
, this doesn't look like a correct behavior.expected behavior
"meta.a"
should remain as-is.meta.a
should be escaped to"meta"."a"