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

NULLS first | last is not rendered to sql #1062

Closed
patricebender opened this issue Mar 6, 2025 · 0 comments · Fixed by #1064 · May be fixed by #1069
Closed

NULLS first | last is not rendered to sql #1062

patricebender opened this issue Mar 6, 2025 · 0 comments · Fixed by #1064 · May be fixed by #1069
Assignees
Labels
bug Something isn't working cqn2sql cqn-to-sql transformation

Comments

@patricebender
Copy link
Member

patricebender commented Mar 6, 2025

When defining null first | last on order by, cqn2sql does not yield the sorting modifier.

> q = SELECT.from(Authors).columns('name', 'dateOfDeath') .orderBy`dateOfDeath asc nulls first`
cds.ql {
  SELECT: {
    from: { ref: [ 'sap.capire.bookshop.Authors' ] },
    columns: [ { ref: [ 'name' ] }, { ref: [ 'dateOfDeath' ] } ],
    orderBy: [ { ref: [ 'dateOfDeath' ], sort: 'asc', nulls: 'first' } ]
  }
}
> q.forSQL()
cds.ql {
  SELECT: {
    from: { ref: [ 'sap.capire.bookshop.Authors' ], as: 'Authors' },
    columns: [
      { ref: [ 'Authors', 'name' ] },
      { ref: [ 'Authors', 'dateOfDeath' ] }
    ],
    orderBy: [ { ref: [ 'dateOfDeath' ], sort: 'asc', nulls: 'first' } ]
  }
}
> q.toSQL()
{
  sql: `
SELECT
    json_insert(
        '{}',
        '$."name"',
        name,
        '$."dateOfDeath"',
        dateOfDeath
    ) as _json_
FROM
    (
        SELECT
            Authors.name,
            Authors.dateOfDeath as dateOfDeath
        FROM
            sap_capire_bookshop_Authors as Authors
        ORDER BY
            dateOfDeath ASC
    )
`,
  values: []
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cqn2sql cqn-to-sql transformation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant