我想从original_content
中提取所有行,其中id
在pipeline_status.oc_version
列中,其中pipeline_status.uuid
= 4f3164b9-6fde-45d6-bd58-86308473b0dc
—我有2个PostgreSQL查询,给了我预期的结果,我想将它们中的任何一个转换为jOOQ:
SELECT oc.* FROM original_content oc
WHERE oc.id = ANY(SELECT unnest(pipeline_status.oc_version) FROM pipeline_status WHERE pipeline_status.uuid='4f3164b9-6fde-45d6-bd58-86308473b0dc' AND pipeline_status.oc_version IS NOT NULL)
-- or
SELECT oc.* FROM original_content oc
WHERE oc.id = ANY(array(SELECT ps.oc_version FROM pipeline_status ps WHERE ps.uuid='4f3164b9-6fde-45d6-bd58-86308473b0dc' AND pipeline_status.oc_version IS NOT NULL))
我生成了DSL,我做了一些事情,比如
dslContext.select(
ORIGINAL_CONTENT.asterisk()
)
.from(ORIGINAL_CONTENT)
.where(ORIGINAL_CONTENT.ID.eq(
DSL.any(DSL.select(PIPELINE_STATUS.OC_VERSION).from(PIPELINE_STATUS).where(PIPELINE_STATUS.UUID.eq(pipelineUuid)))
)
)
但是,我得到了一个错误:
无法解析方法'eq(QuantifiedSelect Record1 T)'<<>>
我该怎么弥补?
我的SQL:
create table public.pipeline_status
(
uuid varchar(50) not null primary key,
oc_version bigint[]
);
create table original_content
(
id bigserial primary key,
name varchar(50) not null,
created_at timestamp default (now() AT TIME ZONE 'UTC'::text) not null
);
insert into pipeline_status (uuid, oc_version)
values ('4f3164b9-6fde-45d6-bd58-86308473b0dc', '{1020,1021}');
insert into original_content (id, name, created_at)
OVERRIDING SYSTEM VALUE
values (1001, 'Name2', '2024-03-22 06:33:12.574244'),
(1021, 'Name2', '2024-03-22 07:33:32.574244'),
(1020, 'Name1', '2024-03-22 09:33:31.574244'),
(1040, 'Name1', '2024-03-22 07:33:51.574244'),
(1002, 'Name3', '2024-03-22 07:33:13.574244');
SELECT oc.* FROM original_content oc
WHERE oc.id = ANY(SELECT unnest(pipeline_status.oc_version) FROM pipeline_status WHERE pipeline_status.uuid='4f3164b9-6fde-45d6-bd58-86308473b0dc' AND pipeline_status.oc_version IS NOT NULL)