db icon indicating copy to clipboard operation
db copied to clipboard

Column names with reserved keywords cause SQL syntax errors

Open francislavoie opened this issue 1 month ago • 0 comments

Bit of a footgun I've just ran into, we have a table with a column named key and that happens to be a reserved keyword, so we get an SQL syntax error.

The BulkInserter query builder should probably backtick-quote the columns. Pretty easy one-liner:

$cols = array_map(static fn($c) => "`{$c}`", $cols);

But maybe it should skip wrapping if already wrapped (user passed already quoted columns). I've pre-wrapped it in my case to work around this for now.

I'll do a PR later (maybe after the holidays if I remember) unless someone else gets to it first.

francislavoie avatar Dec 23 '25 23:12 francislavoie