我有liquibase loadData更改:
<changeSet author="author" id="13">
<sql>SET IDENTITY_INSERT M_Conversion ON</sql>
<loadData tableName="M_Conversion" separator="~" file="data/13-M_Conversion.csv">
<column name="MconID" type="NUMERIC" />
<column name="MdbtID" type="NUMERIC" />
<column name="MlokID" type="NUMERIC" />
<column name="MconKeyword" type="STRING" />
<column name="MconExtra" type="STRING" />
</loadData>
<sql>SET IDENTITY_INSERT M_Conversion OFF</sql>
<rollback>
<sql>SET IDENTITY_INSERTM_Conversion OFF</sql>
</rollback>
</changeSet>
在13-M_Conversion.csv文件中,有一个值会引起MSSQL问题:201~2~200~GETDATE()~
MconKeyword列的GETDATE()值在生成的sql中未用字符串引用
liquibase为此数据生成的sql是:
INSERT INTO [pd].[M_Conversion] ([MconID], [MdbtID], [MlokID], [MconKeyword], [MconExtra]) VALUES (201, 2, 200, GETDATE());
,但应为(201, 2, 200, 'GETDATE()')
问题是,在方法liquibase.sqlgenerator.core.InsertGenerator#generateValues
中,对于字符串值,存在调用以检查字符串是否类似于函数调用
public boolean looksLikeFunctionCall(String value, Database database) {
return value.startsWith("\"SYSIBM\"") || value.startsWith("to_date(") || value.equalsIgnoreCase(database.getCurrentDateTimeFunction());
}
,对于MSSQLDatabase,GETDATE()完全是currentDateTimeFunction
问题是,如何通过loadData更改正确地转义此特定值?