Skip to content

Invalid mysql is produced in MySQLSchemaManager::selectTableColumns #6274

Closed as not planned
@dsentker

Description

@dsentker

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions