【发布时间】:2018-11-07 20:35:23
【问题描述】:
我使用 jOOQ 作为 SQL 构建器,并尝试构建一个简单的更新语句,如下所示:
DSL.using(SQLDialect.POSTGRES_9_5)
.update(table("Location"))
.set(field("speed"), 50)
.set(field("location"), "ST_PointFromText('POINT(-73 40)', 4326)")
.where(field("id").equal(1))
.getSQL(ParamType.INLINED);
如您所见,我使用的是 Postgres 和 PostGIS,所以我需要使用 PostGIS 方法 ST_PointFromText() 插入位置。
生成的 SQL 如下所示,但由于 ST_PointFromText() 被单引号括起来而失败:
update Location
set speed = 50, location = 'ST_PointFromText(''POINT(-73 40)'', 4326)'
where id = 1
查询应该是:
update Location
set speed = 50, location = ST_PointFromText('POINT(-73 40)', 4326)
where id = 1
有什么方法可以去掉 ST_PointFromText() 周围的引号?
【问题讨论】:
标签: java sql postgresql postgis jooq