#4902 - Duplicate ID column in Search
0 guests and 0 members have recently viewed this.
The top 3 point earners from 7th Dec 2025 to 14th Dec 2025.
| PDStig |
|
|
|---|---|---|
| Gabri |
|
|
| Master Rat |
|
|
There are no events at this time
The issue has to be with the 'id' in the SELECT clause, as there is no ambiguous id anywhere else. 'id' comes in from 'r.*' but also 'r.id AS id'. But it's the same field, and we do this pattern pretty commonly.
The MySQL SELECT documentation has this clause saying it is fine:
"MySQL permits duplicate column names. That is, there can be more than one select_expr with the same name. This is an extension to standard SQL"
MariaDB has its own documentation (it can't use MySQL's for copyright reasons), and has no similar clause in it. But that is probably just because they didn't feel a need to go into the same in-depth detail that MySQL's already does.
I even tested on Postgres, and it was fine.
And I trawled the MySQL manual to see if there was some extra strict mode, and there wasn't.
And I tested on the very latest MariaDB and it was fine.
Maybe a bug in a very specific version of MariaDB or MySQL.
Or possibly it's an error message from a previous query, but the mysqli_error function is documented as "Returns the error code for the most recent function call", so it should not be possible. And besides, we should not be having previous queries failing with that either, it's not something we'd sweep under the rug.
All that said, I think I have a fix, and it puts us inline with what other parts of our code already do so I'm happy to include it.
MySQL and MariaDB and Postgres (at least) seem to support selecting multiple columns under the same ID. But we had a report of it not working. Fix any obvious cases of this happening, and alter the XML DB driver to be very strict so that we can pick up on such cases if they happen in the future.