Skip to content

Sequelize does not generate correct SQL query when using the findAll query with a schema that contains fields with '.' characters. #9964

@mbecker16

Description

@mbecker16

What you are doing?

I have a schema with fields such as 'foo.bar.baz'
Sequelize will generate the correct 'Create Table if not exist' query but will not generate a correct
'SELECT' query with this column name. The SELECT that gets generated from this is " SELECT foo.bar.baz from

where . The SELECT query should be "SELECT foo.bar.baz. As a result the db responds with an error, (Responding with error. SequelizeBaseError: ER_BAD_FIELD_ERROR: Unknown column 'foo.bar.baz' in 'field list') which is also misleading.

The following model will reproduce with mySQL db
{
id: {
type: sequelize.UUID,
primaryKey: true
},
'foo.bar.baz': sequelize.TEXT
}

     model.findAll({ where: {id: 123} }).then(
            items => {},
            error => {}
        );

What do you expect to happen?

SELECT foo.bar.baz, id FROM WHERE id = 123

What is actually happening?

SELECT foo.bar.baz, id FROM WHERE id = 123

Output, either JSON or SQL

Dialect: mysql
Database version: AWS Aurora
Sequelize version: 3.30

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugDEPRECATED: replace with the "bug" issue type

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions