Skip to content

Report ambiguous using column MySQL error - #808

Merged
staabm merged 3 commits into
staabm:mainfrom
hemberger:ambiguous-using-column
Oct 10, 2026
Merged

staabm merged 3 commits into
staabm:mainfrom
hemberger:ambiguous-using-column

Conversation

@hemberger

Copy link
Copy Markdown
Contributor

This error occurs when the query reflector simulates a query that refers to columns by ambiguous names, usually due to a JOIN where both tables have the same column name that isn't part of the join condition.

MySQL reports this as error code 1052, and PDO-MySQL reports it as error code 23000.

Previously, no error would be emitted, which silently suppressed this class of MySQL errors.

@hemberger

Copy link
Copy Markdown
Contributor Author

Looks like the static analysis errors are unrelated to this PR. I couldn't remember if I'm supposed to update the cache files, so please let me know if I should remove them. Thank you!

hemberger added a commit to smrealms/smr that referenced this pull request Oct 9, 2026
When we changed to unique player_id values, the game_id column became
a redundancy kept only for convenience. Some queries were relying on
game_id being unique after a JOIN, which we had removed since player_id
was providing that uniqueness conceptually. However, this was not a
concept that was constrained at the MySQL level, so we need to restore
uniqueness for game_id by including it in the USING columns of the JOIN.

Alternatively, we could remove these convenience game_id columns, but I
would prefer to keep them around for now at least.

This error will be identified by phpstan-dba if the following PR is merged:
staabm/phpstan-dba#808
hemberger and others added 3 commits October 10, 2026 08:30
This error occurs when the query reflector simulates a query that refers
to columns by ambiguous names, usually due to a JOIN where both tables
have the same column name that isn't part of the join condition.

MySQL reports this as error code 1052, and PDO-MySQL reports it as error
code 23000.

Previously, no error would be emitted, which silently suppressed this
class of MySQL errors.
@staabm
staabm force-pushed the ambiguous-using-column branch from c61b140 to 52fc573 Compare October 10, 2026 06:30
@staabm
staabm merged commit 6bf4033 into staabm:main Oct 10, 2026
28 checks passed
@staabm

staabm commented Oct 10, 2026

Copy link
Copy Markdown
Owner

awesome, thank you

@hemberger
hemberger deleted the ambiguous-using-column branch October 10, 2026 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants