Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid mysql is produced in MySQLSchemaManager::selectTableColumns #6274

Closed
dsentker opened this issue Jan 25, 2024 · 3 comments
Closed

Invalid mysql is produced in MySQLSchemaManager::selectTableColumns #6274

dsentker opened this issue Jan 25, 2024 · 3 comments

Comments

@dsentker
Copy link
Contributor

dsentker commented Jan 25, 2024

Bug Report

Q A
Version 3.7.3

Summary

The method MySQLSchemaManager::selectTableColumns (source) produces SQL which is not valid. In my case, here is (simplified) the query which was created:

SELECT c.COLUMN_NAME        AS field,
       IF(
                       c.COLUMN_TYPE = 'longtext'
                   AND EXISTS(SELECT *
                              from information_schema.CHECK_CONSTRAINTS
                              WHERE CONSTRAINT_SCHEMA = 'app'
                                AND TABLE_NAME = c.TABLE_NAME -- THE ERROR IS HERE
                                AND CHECK_CLAUSE = CONCAT(
                                      'json_valid(`',
                                      c.COLUMN_NAME,
                                      '`)'
                                  )),
                       'json',
                       c.COLUMN_TYPE
           )                AS type

FROM information_schema.COLUMNS c
         INNER JOIN information_schema.TABLES t
                    ON t.TABLE_NAME = c.TABLE_NAME
WHERE c.TABLE_SCHEMA = "app"
  AND t.TABLE_SCHEMA = "app"
  AND t.TABLE_TYPE = 'BASE TABLE'
  AND t.TABLE_NAME = "doctrine_migration_versions"
ORDER BY ORDINAL_POSITION

Current behaviour

The query leads to the message "[1052] Column 'TABLE_NAME' in where clause is ambiguous" which is produced in the AND EXISTS() subquery.

This errors leads to unusable doctrine/migrations command calls as this method is invoked.

How to reproduce

Run the query i pasted here.

Expected behaviour

The sql is valid.

@nroehling
Copy link

I have the same issue

@derrabus
Copy link
Member

Closing as this is not a bug, see #6275 (comment)

@derrabus derrabus closed this as not planned Won't fix, can't repro, duplicate, stale Jan 25, 2024
derrabus pushed a commit that referenced this issue Feb 1, 2024
<!-- Fill in the relevant information below to help triage your pull
request. -->

|      Q       |   A
|------------- | -----------
| Type         | bug
| Fixed issues | #6274 

#### Summary

The current produced query leads to an ambigous column reference as
described in the linked issue.
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants