【问题标题】:Does jOOQ support PostgreSQL's C style escape strings?jOOQ 是否支持 PostgreSQL 的 C 风格转义字符串?
【发布时间】:2018-03-25 16:10:57
【问题描述】:

jOOQ 是否支持 PostgreSQL 的 C 风格转义字符串?

我有查询我在哪里分页(限制和偏移样式)并通过解析 EXPLAIN 的输出返回总计数,这是 PostgreSQL wiki 获得快速计数估计的推荐方法之一( https://wiki.postgresql.org/wiki/Count_estimate)。当我最初实现这个函数时,我使用 PG 的 C 风格转义(https://www.postgresql.org/docs/9.5/static/sql-syntax-lexical.html 的第 4.1.2.2 节)转义了这个函数。以下是根据 PG 的有效查询,但是当尝试在 jOOQ Tools#renderAndBind(Context<?>, String, List<QueryPart>) 中呈现它时会抛出 ArrayIndexOutOfBoundsException,因为它会在搜索词中选择双引号作为标识符的开头并在数组末尾运行正在寻找另一个。

select 
  (
    select count_estimate(E'select 1
    from "public"."foo"
    where (
        "public"."foo"."name" = \'"\'
    )')
  ) as "total", 
  (
    select array_to_json(coalesce(
      array_agg("alias_95585617"."data" order by 
        "alias_95585617"."name" asc nulls last
      ), 
      cast('{}' as jsonb[])
    ))
    from (
      select
          "public"."foo"."name",
          row(
              "public"."foo"."id",
              "public"."foo"."name"
          ) as "data"
      from "public"."foo"
      where (
        "public"."foo"."name" = '"'
      )
      order by 
        "public"."foo"."name" asc nulls last
      limit 30
      offset 120
    ) as "alias_95585617"
  ) as "data"

在 jOOQ 中使用双美元引号重新实现此功能可以按预期工作。我打算将此作为错误提交,但我想我会检查这是 jOOQ 打算首先支持的 PG 功能。

使用(Oracle JDK 1.8.0_144、jOOQ 3.8.3、PG 9.5.5、PGJDBC 42.1.4)

【问题讨论】:

    标签: postgresql jooq


    【解决方案1】:

    不,jOOQ 3.10 尚不支持此功能。但这当然是有道理的。我在路线图中添加了一个问题:https://github.com/jOOQ/jOOQ/issues/6704

    【讨论】:

      猜你喜欢
      • 2015-03-24
      • 1970-01-01
      • 1970-01-01
      • 2013-08-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多