Skip to content

copyfrom in MySQL with sqlc does not recognize reserved keywords and does not escape column names manually or automatically #3984

Open
@Umamad

Description

@Umamad

Summary

Using :copyfrom in MySQL with sqlc and column names that are reserved keywords like create, read, update, delete fails with a MySQL syntax error, even if escaped.

Expected behavior

sqlc should either:

  • Automatically escape column names in the generated LOAD DATA LOCAL INFILE statement, or
  • Respect backticks in -- columns: directive

Actual behavior

The generated Go code produces a raw SQL string like:

LOAD DATA LOCAL INFILE 'Reader::xyz' INTO TABLE `role_system` (...) (role_id, system_id, create, read, update, delete)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions