Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code generation problem: using reserved word as column name #1028

Open
alexanderfefelov opened this issue Jun 28, 2019 · 3 comments
Open

Code generation problem: using reserved word as column name #1028

alexanderfefelov opened this issue Jun 28, 2019 · 3 comments

Comments

@alexanderfefelov
Copy link

DDL of my table is

CREATE TABLE `address_config` (
  `table_id` varchar(50) NOT NULL,
  `record_id` int(11) NOT NULL,
  `key` varchar(50) NOT NULL,
  `value` mediumtext NOT NULL,
  PRIMARY KEY (`table_id`,`record_id`,`key`)
)

Reversed code contains this fragment

object AddressConfig extends SQLSyntaxSupport[AddressConfig] {
  override val tableName = "address_config"
  override val columns = Seq("table_id", "record_id", "key", "value")

Generated SQL query

insert into address_config ( table_id, record_id, key, value ) values (...)

throws error You have an error in your SQL syntax.

Valid query may looks like

insert into address_config ( table_id, record_id, `key`, value ) values (...)

or

insert into address_config ( table_id, record_id, address_config.key, value ) values (...)

Environment:

  • MySQL Server 5.7.25
  • MySQL Connector/J 5.1.47
  • scalikejdbc-mapper-generator 3.3.5
@seratch
Copy link
Member

seratch commented Jun 28, 2019

@alexanderfefelov
Copy link
Author

The problem is the key banned by SQL, not Scala.

columnNameToFieldName affects Scala code, not SQL.

@seratch
Copy link
Member

seratch commented Jun 28, 2019

Ah, you’re right

@seratch seratch added this to the version 5.0.x milestone Jun 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants