我在创建用于 Spring Boot 测试的 H2 数据库视图时遇到问题。 使用 PostgreSQL 数据库在常规启动时可以很好地创建视图,但在 H2 中会失败并出现以下错误:
Column "prov.block_id" not found
我很确定 H2 引擎在我的视图创建中无法理解某些内容,但我不确定是什么。
CREATE VIEW my_view AS
SELECT CASE
WHEN EXISTS (SELECT 1
FROM signal si
LEFT JOIN block b
ON prov.block_id= b.id AND si.signal_id = b.id AND si.type = 'BLOCK'
LEFT JOIN prov p_direct
ON si.signal_id = p_direct.id AND ms.type = 'PROV'
LEFT JOIN slot s
ON prov.slot_id= s.id AND si.signal_id = s.id AND si.type = 'SLOT'
LEFT JOIN beam b
ON s.beam_id = b.id AND si.type = 'BEAM'
WHERE si.status = 'VALID'
AND (
prov.block_id = b.id
OR prov.id = p_direct.id
OR prov.slot_id = s.id
OR s.beam_id = b.id
)) THEN TRUE
ELSE FALSE
END AS is_ok,
slot.beam_id AS b_id,
prov.name
FROM public.prov prov
LEFT JOIN public.slot slot ON prov.slot_id = slot.id;
FROM 信号 si LEFT JOIN 块 b ON prov.block_id= b.id AND si.signal_id = b.id AND si.type = 'BLOCK'
在此级别,您的 prov.block_id 不可见。稍后添加