【发布时间】:2013-05-16 11:53:44
【问题描述】:
我正在使用 liquibase 和 hsqldb 数据库。
我有一个 .sql 文件,其中包含用于在引导程序中填充数据库的“插入”指令,但如果一个字符串包含两个彼此接近的减号,它将被解释为注释而不是字符串。
这里我在 liquibase 加载的 .sql 文件中的 sql 指令:
INSERT INTO user (id,firstname,lastname,mystring) VALUES
(11,'Wendy','Salinas','this is my string--and it continues'),
(12,'Kirsten','Parker','this is the string of Kirsten')
还有我的堆栈跟踪:
liquibase.exception.DatabaseException: Error executing SQL INSERT INTO user (id,firstname,lastname,mystring) VALUES
(11,'Wendy','Salinas','this is my string
(12,'Kirsten','Parker','this is the string of Kristen')
Caused by: java.sql.SQLSyntaxErrorException: unexpected token: KIRSTEN required: ) : line: 12
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCStatement.fetchResult(Unknown Source)
at org.hsqldb.jdbc.JDBCStatement.execute(Unknown Source)
at org.apache.commons.dbcp.DelegatingStatement.execute(DelegatingStatement.java:264)
at org.apache.commons.dbcp.DelegatingStatement.execute(DelegatingStatement.java:264)
at liquibase.executor.jvm.JdbcExecutor$1ExecuteStatementCallback.doInStatement(JdbcExecutor.java:92)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)
有没有办法为 liquibase 使用的 sql 文件转义字符串中的 cmets?
如何在 liquibase 使用的 .sql 文件中的字符串中转义“--”?
【问题讨论】:
-
您应该在 Liquibase 论坛上报告此问题。听起来像一个错误。
-
是的,我做到了。 forum.liquibase.org/#Topic/49382000000708003 但暂时没有答案
标签: mysql sql database hsqldb liquibase