node-postgres
node-postgres copied to clipboard
Passing in quoted tabled names for a create table query
I want to be able to create a tabled named "user" so I wrote this piece of code:
const client = await this.pool.connect();
sql= 'CREATE TABLE IF NOT EXISTS "user" (id UUID PRIMARY KEY DEFAULT gen_random_uuid())';
await client.query(sql);
When I run the code, I get a parser error. If I run it with user without the quotation marks, I get an error for user is a special name for postgres. I have since found a round about solution to my initial problem which I was trying to use this library to solve.
Since I ran into this dilemma and I don't want other developers to fall into this pitfall, I think this would be the best place to bring it up. If you can't solve the issue, that's fine, but I thought it would be best for contributors and future developers to know about this issue. :)