You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when using recursive query, it can not generate related go code.
Relevant log output
# package gen
sql/query/dict.sql:1:1: edited query syntax is invalid: syntax error at or near ","
Database schema
createtabledict(
id VARCHAR(36) PRIMARY KEY DEFAULT gen_random_uuid(),
app_id VARCHAR(36) NOT NULL,
code VARCHAR(64),
parent_code VARCHAR(64) NOT NULL,
label TEXTNOT NULL DEFAULT '',
value TEXTNULL,
weight INTNOT NULL DEFAULT 0,
is_default BOOLEANNOT NULL DEFAULT false,
is_virtual BOOLEANNOT NULL DEFAULT false,
status SMALLINTNOT NULL DEFAULT 1,
create_at TIMESTAMPTZ(0) NOT NULL DEFAULT now(),
create_by VARCHAR(36) NOT NULL DEFAULT '',
update_at TIMESTAMPTZ(0),
update_by VARCHAR(36),
is_delete BOOLEANNOT NULL DEFAULT false
);
-- test caseinsert into dict(app_id, code, parent_code, label) values('1','test.l1','','layer1');
insert into dict(app_id, code, parent_code, label) values('1','test.l2-1','test.l1','layer2-1');
insert into dict(app_id, code, parent_code, label) values('1','test.l2-2','test.l1','layer2-2');
insert into dict(app_id, code, parent_code, label) values('1','test.l3-1','test.l2-2','test.l3-1');
insert into dict(app_id, code, parent_code, label) values('1','test.l4-1','test.l3-1','test.l4-1');
insert into dict(app_id, parent_code, label, value) values('1','test.l4-1','l4-1-v1', '1');
insert into dict(app_id, parent_code, label, value) values('1','test.l4-1','l4-1-v2', '1');
SQL queries
-- name: GetDictTree :many
with recursive dictTree(id, code, parent_code, label, value, path, depth) AS (
select id, code, parent_code, label, value, ARRAY[COALESCE((select id from dict where code=''),'virtual_root'), id], 1as depth from dict where app_id ='1'and parent_code =''and is_delete=false
unionselectd.id, d.code, d.parent_code, d.label, d.value, t.path|| ARRAY[d.id], t.depth+1as depth from dict d join dictTree t ond.parent_code=t.codeand not d.id= ANY(t.path) andd.is_delete=false
)
select*from dictTree d order by depth, parent_code;
Version
1.10.0
What happened?
when using recursive query, it can not generate related go code.
Relevant log output
Database schema
SQL queries
Configuration
Playground URL
No response
What operating system are you using?
macOS
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go
The text was updated successfully, but these errors were encountered: