Skip to content

Escaped table name causes incorrect query generation for MySQL connector #82

@slvrtrn

Description

@slvrtrn

Given a simple table to test the things out

CREATE TABLE `users` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` text NOT NULL,
  `registered_at` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
  PRIMARY KEY (`id`)
) ENGINE = InnoDB;

and the following connector config

const mysqlConnectorConfig = {
  options: {
    host: env.DB_HOST,
    dialect: 'mysql',
    pool: {
      max: 5,
      min: 0,
      idle: 10000,
    },
  },
  database: env.DB_DATABASE,
  user: env.DB_USERNAME,
  password: env.DB_PASSWORD,
  maxPollCount: 100,
  incrementingColumnName: 'id',
  timestampColumnName: 'registered_at',
  fetchMode: 'timestamp',
  table: `users`,
  initTimestamp: env.KAFKA_CONNECT_USERS_INIT_TIMESTAMP,
};

the following error pops up in the console when the application and the polling are started:

Executing (default): SELECT * FROM 'users' ORDER BY 'id' LIMIT 100 OFFSET 0
[09:25:11.892] ERROR (SequelizeDatabaseError): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''users' ORDER BY 'id' LIMIT 100 OFFSET 0' at line 1
    SequelizeDatabaseError: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''users' ORDER BY 'id' LIMIT 100 OFFSET 0' at line 1

this seems to be the culprit: https://github.com/nodefluent/sequelize-kafka-connect/blob/master/lib/source/SequelizeSourceTask.js#L41
as I remove the escaping here, that select works as expected without errors.

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