Skip to content

ValidationException occurs when accessing the column with table's alias #1502

@qwefgh90

Description

@qwefgh90

Describe the bug
When accessing the column with table's alias, ValidationException occurs because of the wrong validation order.

To Reproduce
Steps to reproduce the behavior:

  1. SQL
        var errors = parserUtils.validate(
                "select b.id, name ,(select name from Blog where name = 'sadf') as name2 \n" +
                        ", category, owner, b.update_time \n" +
                        "from Blog as b \n" +
                        "left join Content\n" +
                        "ON b.id = Content.blog_id  \n" +
                        "where name = 'sadf' order by Content.title desc"
                ,capa
        );
  1. Parsing this SQL using JSqlParser with this statements
        Validation validation = new Validation(Arrays.asList(capability()), stmt);
        List<ValidationError> errors = validation.validate();
        return errors;
  1. Produce wrong results after validation().
capability=meta data
errors=[ValidationException: b.id does not exist., UnexpectedValidationException: name: cannot validate column-name. detail: fully qualified name must not be null, UnexpectedValidationException: name: cannot validate column-name. detail: fully qualified name must not be null, ValidationException: b.update_time does not exist.]
]]

Expected behavior
b.id, b.update_time must exist. and It should not throw ValidationException.

System

  • Database you are using: mysql 8
  • Java Version: jdk 13
  • JSqlParser version: v4.3

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