user3346601
user3346601

Reputation: 1049

Slick - MySQL Syntax Error

I'm using the Play Framework (2.3.1) together with Slick (play-slick version 0.8.0-M1) and a MySQL Database (5.5.28).

One of my queries results in a MySQLSyntaxErrorException:

Preparing statement: select x2."id", x2."course_id", x2."trainee_id", x2."transaction_id" from "trainee_grouptraining_GroupBooking" x2 where x2."course_id" = 1

The problem appears to be with the double quotation marks, since other queries work just fine and they use single quotation marks like the following:

Preparing statement: select x2.`id`, x2.`courseLanguage`, x2.`date`, x2.`description`, x2.`duration`, x2.`kind`, x2.`maxParticipants`, x2.`name`, x2.`courseType_id`, x2.`trainer_id` from `Course` x2 where x2.`id` = 1

What can i do about this?

Upvotes: 4

Views: 1127

Answers (2)

Mihail Burduja
Mihail Burduja

Reputation: 3266

I guess you are importing

scala.slick.driver.JdbcDriver.simple._

You should import

scala.slick.driver.MySQLDriver.simple._

instead.

Upvotes: 9

VMai
VMai

Reputation: 10346

MySQL is using per default backticks to quote identifiers. You could use the SQL Mode ANSI_QUOTES to enable double quotes

ANSI_QUOTES

Treat " as an identifier quote character (like the ` quote character) and not as a string quote character. You can still use “`” to quote identifiers with this mode enabled. With ANSI_QUOTES enabled, you cannot use double quotation marks to quote literal strings, because it is interpreted as an identifier.

or simply use backticks.

Upvotes: 0

Related Questions