pmusa's avatar
Level 2

SQLSTATE[HY000]: General error: 1 no such column

Line 22 here is causing an error during PHPUnit tests (I use SQLite in memory for tests, but MySQL for dev/prod): https://i.imgur.com/pGqhwv0.png

Error detail : https://i.imgur.com/oV6vPDC.png

And here is the migration where you can clearly see the column does exist: https://i.imgur.com/bunZCsH.png

I can't figure what's wrong. Can you help? Please note that everything works fine in dev.

Here is the test, just in case: https://i.imgur.com/ptBDZzm.png

Tests were all green until I added the created() model observer with the DB facade that performs a updateOrInsert() I suspect the updateOrInsert() to be the culprit here with SQLite, since it tries to create (insert) a row and increment the colum "comments_count" which does not exist yet for that row --> comments_count = comments_count +1 Thanks

0 likes
1 reply
Tray2's avatar

SQL very rarely lies when it comes to the error messages. They might be cryptic somethimes but rarely wrong. If it says that the column is missing then it's missing.

Are you using an in memory database for your testing?

Try switching to a filebased one and comment out the down methods for your migrations. Then check there to see if the table has the column.

Please use three backticks and paste your code here instead of linking to images.

Please or to participate in this conversation.