Karate 当字符串值中包含“-”时,JSON对象中的值将被截断

Karate 当字符串值中包含“-”时,JSON对象中的值将被截断,karate,Karate,我想使用包含“-”符号的SQL查询sampleId从数据库中获取值,但是,查询字符串被截断 下面是我的一些脚本,其中sampleId是从上次API调用中获取的: * json result = response[0].result * print result * def personId = result[0].personid * def sampleId = result[0].sampleid 给定路径“srehr/SendSample” * de

我想使用包含“-”符号的SQL查询sampleId从数据库中获取值,但是,查询字符串被截断

下面是我的一些脚本,其中sampleId是从上次API调用中获取的:

   * json result = response[0].result
    * print result
    * def personId = result[0].personid
    * def sampleId = result[0].sampleid
给定路径“srehr/SendSample”

    * def config = read('classpath:utils/yntestDBConfig.json')
    * def DbUtils = Java.type('utils.DBUtils')
    * def db = new DbUtils(config)

    * def foo = {getBatchIDSQL: '#("select operatetime from sr_sendreceive_sample where sampleid = " + sampleId)'}
    * print foo.getBatchIDSQL
以下是报告中指定的日志:

09:00:06.130[打印]从样本ID=1cfacfa4-eb06-4413-b060-9507bdebd1eb的sr_sendreceive_样本中选择操作时间

mainFlow.feature:72-javascript评估失败:db.readValuefoo.getBatchIDSQL,StatementCallback;错误的SQL语法[从sr_sendreceive_示例中选择operatetime,其中sampleid=1cfacfa4-eb06-4413-b060-9507BD1EB];嵌套异常为java.sql.SQLSyntaxErrorException:where子句中的未知列“1cfacfa4”


我的问题:从日志中,您可以看到未知列“1cfacfa4”不是预期的,它应该是“1cfacfa4-eb06-4413-b060-9507bdebd1eb”

尝试将SQL中的字符串括在引号内:

* def sql = "select operatetime from sr_sendreceive_sample where sampleid = '" + sampleId + "'"

好的,我看到查询应该是:从sr_sendreceive_sample中选择operatetime,其中sampleid='1cfacfa4-eb06-4413-b060-9507BD1EB'。但是,如何标记sampleId单引号?请仔细阅读: