Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: package-lock maintenance #1113

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

chore: package-lock maintenance #1113

wants to merge 5 commits into from

Conversation

johannes-vogel
Copy link
Contributor

No description provided.

@johannes-vogel
Copy link
Contributor Author

@patricebender @BobdenOs Could one of you have a look at the failing test? I only increased the cds version which seems to lead to a test failure. I'd like to understand why we did not detect this internally.

@johannes-vogel
Copy link
Contributor Author

johannes-vogel commented Apr 4, 2025

I've tracked down the failing test

test('Books $count in expand', async () => {

It produces the following SQL statement:

WITH "$A" as (
    SELECT *,
        '$[' || lpad("$$RN$$", 6, '0') as _path_
    FROM (
            SELECT *,
                ROW_NUMBER() OVER (
                    ORDER BY ID ASC
                ) as "$$RN$$"
            FROM (
                    SELECT "$A".name,
                        "$A".ID,
(
                            SELECT count(*) as "COUNT"
                            FROM localized_AdminService_Books as "$B"
                                inner JOIN "$A" as "$A" ON "$A".ID = "$B".author_ID
####### above inner joins fails, was a where clause before
                        ) as "[email protected]"
                    FROM AdminService_Authors as "$A"
                    ORDER BY ID ASC
                    LIMIT 1000
                ) as "$A"
        ) as "$A"
),
"$A_BOOKS" as (
    SELECT *,
        _parent_path_ || '].books[' || lpad("$$RN$$", 6, '0') as _path_
    FROM (
            SELECT *,
                ROW_NUMBER() OVER (PARTITION BY _parent_path_) as "$$RN$$"
            FROM (
                    SELECT "$B".createdAt,
                        "$B".createdBy,
                        "$B".modifiedAt,
                        "$B".modifiedBy,
                        "$B".ID,
                        "$B".title,
                        "$B".descr,
                        "$B".author_ID,
                        "$B".genre_ID,
                        "$B".stock,
                        "$B".price,
                        "$B".currency_code,
                        "$B".footnotes,
                        "$B".authorsAddress,
case
                            when "$B".image IS NULL then ?
                            else coalesce(?, ?)
                        end as "[email protected]",
                        "$A"._path_ as _parent_path_
                    FROM localized_AdminService_Books as "$B"
                        inner JOIN "$A" as "$A" ON "$A".ID = "$B".author_ID
                ) as "$B"
        ) as "$B"
)
SELECT *
FROM (
        SELECT _path_ as "_path_",
            '{}' as "_blobs_",
            '{"books":[]}' as "_expands_",
(
                SELECT name as "name",
                    ID as "ID",
                    TO_NVARCHAR("[email protected]") as "[email protected]"
                FROM JSON_TABLE(
                        '{}',
                        '$' COLUMNS("'$$FaKeDuMmYCoLuMn$$'" FOR ORDINALITY)
                    ) FOR JSON ('format' = 'no', 'omitnull' = 'no', 'arraywrap' = 'no') RETURNS NVARCHAR(2147483647)
            ) as "_json_"
        FROM "$A"
    )
UNION ALL
(
    SELECT _path_ as "_path_",
        '{}' as "_blobs_",
        '{}' as "_expands_",
        '{"footnotes":' || COALESCE(footnotes, 'null') || ',' || SUBSTRING(
            (
                SELECT to_char(createdAt, 'YYYY-MM-DD"T"HH24:MI:SS.FF3"Z"') as "createdAt",
                    createdBy as "createdBy",
                    to_char(modifiedAt, 'YYYY-MM-DD"T"HH24:MI:SS.FF3"Z"') as "modifiedAt",
                    modifiedBy as "modifiedBy",
                    ID as "ID",
                    title as "title",
                    descr as "descr",
                    author_ID as "author_ID",
                    genre_ID as "genre_ID",
                    stock as "stock",
                    TO_NVARCHAR(price) as "price",
                    currency_code as "currency_code",
                    authorsAddress as "authorsAddress",
                    "[email protected]" as "[email protected]"
                FROM JSON_TABLE(
                        '{}',
                        '$' COLUMNS("'$$FaKeDuMmYCoLuMn$$'" FOR ORDINALITY)
                    ) FOR JSON ('format' = 'no', 'omitnull' = 'no', 'arraywrap' = 'no') RETURNS NVARCHAR(2147483647)
            ),
            2
        ) as "_json_"
    FROM "$A_BOOKS"
)
ORDER BY "_path_" ASC

cqn4sql looks ok, does it ring a bell @BobdenOs ? could also be caused by the quoted aliases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants