Skip to content

Using "for json path" in formula generates wrong sql. #2338

Open
@marjohansson

Description

@marjohansson

Hi,

I tried to use a formula with "for json path" to return the result as a json string.
(Maybe I am doing something wrong here then I apologize.)

Formula from hbm file.
" (select
sum(j.FullSuccessfulBackupDataLength) as FullValue,
sum(j.DiffSuccessfulBackupDataLength) as DiffValue,
sum(j.IncrSuccessfulBackupDataLength) as IncValue,
sum(j.LogSuccessfulBackupDataLength) as LogValue,
sum(j.DupSuccessfulBackupDataLength) as DupValue,
sum(j.DedupSuccessfulBackupDataLength) as DedupValue
from BackupBinder b
join BackupJobUnit j on j.Binder_cid = b.cid
where b.cid=Cid and j.Status_cid=67
for json path, include_null_values, Without_Array_Wrapper)"

The SQL generated.
(select
sum(j.FullSuccessfulBackupDataLength) as binder0_.FullValue,
sum(j.DiffSuccessfulBackupDataLength) as binder0_.DiffValue,
sum(j.IncrSuccessfulBackupDataLength) as binder0_.IncValue,
sum(j.LogSuccessfulBackupDataLength) as binder0_.LogValue,
sum(j.DupSuccessfulBackupDataLength) as binder0_.DupValue,
sum(j.DedupSuccessfulBackupDataLength) as binder0_.DedupValue
from BackupBinder b
join BackupJobUnit j on j.Binder_cid = b.cid
where b.cid=binder0_.Cid and j.Status_cid=67
for binder0_.json path, binder0_.include_null_values, binder0_.Without_Array_Wrapper)

If not trying to return the string as json it works perfectly.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions