ohffs's avatar
Level 50

Non-existent columns in sqlite

I was re-factoring some code and all my tests against sqlite were passing - 'oh good!'... I thought. Then ran the code against mysql and it blew up.

Turns out in sqlite if you do :

select non-existing-column from table;

It gives an error, but if you do :

select "non-existing-column" from table;

It doesn't. Which is... interesting ;-). In my case it was an 'orderby' clause which was still running against a column which had been renamed - sqlite just went 'yeah, sure, whatever' - mysql wasn't so happy though.

Eloquent (possibly PDO itself, not sure) wraps the field names in quotes, so you will not get the error back from sqlite.

Anyway - wasn't sure if anyone else had come across this and there was a work-around. I know sqlite is pretty forgiving of most things - but the quoted-vs-not-quoted was a new one on me!

0 likes
0 replies

Please or to participate in this conversation.