Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] "user" table in Postgresql is a reserved keyword #536

Open
diaznet opened this issue Jul 17, 2024 · 0 comments
Open

[BUG] "user" table in Postgresql is a reserved keyword #536

diaznet opened this issue Jul 17, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@diaznet
Copy link

diaznet commented Jul 17, 2024

Describe the bug
A run_migrations task in webapp was stuck indefinitely. I understood this was in relatiiopn with eacb390
We sawt an attempt at altering "user" table in Iris DB. While troubleshooting we saw a potential issue.
The table exists and has valid data inside. However the name "user" is also a reserved keyword for PostgreSQL.

This query returns the current db active user:

iris_db_prod=> select * from user;
user

db_admin_user
(1 row)

db_admin_user is the user we use to connect to the DB (via POSTGRES_USER and POSTGRES_ADMIN_USER).

When quoting user, then we get the content of iris_db_prod > user table

iris_db_prod=> select * from "user";
id | user | name | email | uuid | ...
----+-----------------------------------+----------------------+-----------------------------------+--------------------------------------+- ...
1 | [email protected] | User1 | [email protected] | xxx | ...
2 | [email protected] | User2 | [email protected] | xxx | ...
(2 rows)

Also with specifying public schema:

iris_db_prod=> select * from public.user;
id | user | name | email | uuid | ...
----+-----------------------------------+----------------------+-----------------------------------+--------------------------------------+- ...
1 | [email protected] | User1 | [email protected] | xxx | ...
2 | [email protected] | User2 | [email protected] | xxx | ...
(2 rows)

To Reproduce
Steps to reproduce the behavior:

  1. Use Postgres 16
  2. Check commands posted above

Expected behavior
"user" keyword as table name should not be used. A quick Google search returns plenty of these conclusions.

Additional context
user is a reserved keyword in PosgreSQL 16 documentation, therefore it is best practice to not use it, especially as table name, otgherwise this leads to unexpected behavior like above.

@diaznet diaznet added the bug Something isn't working label Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant