使用 hsqldb 进行 liquibase 表命名时出错(在内存中)。需要解决方法
我在一个项目上使用 liquibase,我刚刚意识到是什么让我的构建失败。我已经成功地使用命令行generateChangeLog 针对 mysql 中的相同模式,并将该文件包含在我的 master-change-log 文件中。
对于测试环境,我使用 hsqldb。现在所有表名都用连字符与语言分开。由于我的构建失败,我打开了 mydb.script,所有连字符分隔的表名称都是大写,但语言看起来像这样,
CREATE MEMORY TABLE SOME_TABLE(ID BIGINT NOT NULL,OBJ_VESION INTEGER DEFAULT 0 NOT NULL,REQUESTER_PHONE VARCHAR(20),FORM_CODE VARCHAR(100),DATE_STARTED TIMESTAMP,DATE_ENDED TIMESTAMP,LAST_ACTIVITY TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,SOME_TABLE_STATUS VARCHAR(255),CONSTRAINT PK_INCOMING_MESSAGE_SESSION PRIMARY KEY(ID))
CREATE MEMORY TABLE "language"(ID BIGINT NOT NULL,CODE VARCHAR(10),NAME VARCHAR(50),DESCRIPTION VARCHAR(255),CONSTRAINT PK_LANGUAGE PRIMARY KEY(ID))
并且在更改日志中文件它们看起来像这样,
<changeSet author="highjo (generated)" id="1282409084036-10">
<createTable tableName="some_table">
<column name="id" type="BIGINT">
<constraints nullable="false" primaryKey="true"/>
</column>
<column defaultValueNumeric="0" name="obj_vesion" type="INT">
<constraints nullable="false"/>
</column>
<!-- ... -->
</createTable>
</changeSet>
<changeSet author="highjo (generated)" id="1282409084036-11">
<createTable tableName="language">
<column name="id" type="BIGINT">
<constraints nullable="false" primaryKey="true"/>
</column>
<column name="code" type="VARCHAR(10)"/>
<!-- .... -->
</createTable>
</changeSet>
因为您可以注意到它们在更改日志文件中都是小写字母。我尝试将更改日志语言更改为大写,在脚本中它是大写的,只是它仍然有双引号。 :(
如何解决这个问题?感谢您的阅读。
I'm using liquibase on a project and i just realize what makes my build fails.i've successfully use command line generateChangeLog against the same schema in mysql and included that file in my master-change-log file.
For test environment i use hsqldb.Now all the table name are hyphen separated apart from language.Since my build were failing i opened my mydb.script and all the hyphen separated Tables name were in capital but language looks like this
CREATE MEMORY TABLE SOME_TABLE(ID BIGINT NOT NULL,OBJ_VESION INTEGER DEFAULT 0 NOT NULL,REQUESTER_PHONE VARCHAR(20),FORM_CODE VARCHAR(100),DATE_STARTED TIMESTAMP,DATE_ENDED TIMESTAMP,LAST_ACTIVITY TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,SOME_TABLE_STATUS VARCHAR(255),CONSTRAINT PK_INCOMING_MESSAGE_SESSION PRIMARY KEY(ID))
CREATE MEMORY TABLE "language"(ID BIGINT NOT NULL,CODE VARCHAR(10),NAME VARCHAR(50),DESCRIPTION VARCHAR(255),CONSTRAINT PK_LANGUAGE PRIMARY KEY(ID))
and in the change log file they look like this
<changeSet author="highjo (generated)" id="1282409084036-10">
<createTable tableName="some_table">
<column name="id" type="BIGINT">
<constraints nullable="false" primaryKey="true"/>
</column>
<column defaultValueNumeric="0" name="obj_vesion" type="INT">
<constraints nullable="false"/>
</column>
<!-- ... -->
</createTable>
</changeSet>
<changeSet author="highjo (generated)" id="1282409084036-11">
<createTable tableName="language">
<column name="id" type="BIGINT">
<constraints nullable="false" primaryKey="true"/>
</column>
<column name="code" type="VARCHAR(10)"/>
<!-- .... -->
</createTable>
</changeSet>
as you can notice they are all in small letters in the changelog file.I've tried changing in the change log language to capital, and in the script it is in capital just that it still has the double quote. :(
How it is possible to fix this? thanks for reading.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为语言被引用的原因是因为它使用了 hsql 中的保留字,因此 liquibase 引用它,这样 SQL 就不会失败。
liquibase 2.0 的转义规则可能已更改,但如果没有更改,您可以更轻松地重写 q 自定义数据库类中的 escapeObject 方法并查看它是否有效。
不过,引号应该不重要。它们不应出现在表名称本身中。
I think the reason language is quoted is because it us a reserved word in hsql and so liquibase quotes it so the SQL doesn't fail.
The escaping rules may have changed for liquibase 2.0, but if not you could override the escapeObject method in q custom database class easier and see if it works.
The quotes shouldn't matter, though. They shouldn't occur in the table name itself.