Column doesn't exist when creating table
See original GitHub issueBasic info
pg-mem version: 1.9.9 jest version: 27.0.4 typeorm version: 0.2.35
Reproduction link: https://gist.github.com/Sven65/5b462e2d2d4ded3d8f89d4792bf4fd6b
Issue
When trying to create a table using pg-mem and typeorm entities, it fails as the column doesn’t exist, with the following error message:
QueryFailedError: column "userid" does not exist
🐜 This seems to be an execution error, which means that your request syntax seems okay,
but the resulting statement cannot be executed → Probably not a pg-mem error.
*️⃣ Failed SQL statement: CREATE TABLE "userStats" ("userID" character varying(255) NOT NULL, CONSTRAINT "UQ_abb77da609fd701b7052a8b4531" UNIQUE ("userID"), CONSTRAINT "PK_abb77da609fd701b7052a8b4531" PRIMARY KEY ("userID"));
Stacktrace
at QueryFailedError.TypeORMError [as constructor] (src/error/TypeORMError.ts:7:9)
at new QueryFailedError (src/error/QueryFailedError.ts:9:9)
at PostgresQueryRunner.call (src/driver/postgres/PostgresQueryRunner.ts:258:19)
at step (node_modules/typeorm/node_modules/tslib/tslib.js:143:27)
at Object.throw (node_modules/typeorm/node_modules/tslib/tslib.js:124:57)
at rejected (node_modules/typeorm/node_modules/tslib/tslib.js:115:51)
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:6 (1 by maintainers)
Top Results From Across the Web
PostgreSQL "Column does not exist" but it actually does
This problem occurs in postgres because the table name is not tablename instead it is "tablename". for eg. If it shows user as...
Read more >PostgreSQL column does not exist | Definition and Syntax
The column does not exist exception occurs in PostgreSQL when we have not used a specified column name while doing any operations. Also,...
Read more >How to Fix Column Does not Exist Exception/Error in ...
In PostgreSQL, the “column doesn't exist” error can occur because of various reasons, such as the searched column doesn't exist in the targeted ......
Read more >Troubleshooting - Column does not exist - Workato Docs
UndefinedColumn - Column Does Not Exist is a type of SQL statement error. It indicates that the database cannot find the specified column....
Read more >ERROR: column “…” does not exist - Pinter Computing
The first line of the error message shows, that PostgreSQL internally converted UserName to username. To be able to reference the column, use ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi ! I just fixed it.
I still have several (unrelated) unit tests to fix, but it will be published with the next pg-mem version, hopefully a bit later this week.
Thanks for the feedback 😃
More of my investigation. The problem is not on
pg-membut more onpgsql-ast-parser. When it parses the constraints, it transforms the column name in lowercase.If I take the SQL code generated by the @Sven65 code, and I put it on the pg-mem playground, we can see that it fails saying that column
useriddoes not exist:But with everything in lowercase, it works:
I will create a ticket on
pgsql-ast-parserrepository…