Skip to content

Commit

Permalink
Add missing properties in cqn.SELECT (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
daogrady authored Nov 26, 2024
1 parent bbc12e5 commit 29cbcd7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
- Added missing types for `Request.on('succeeded' | 'failed' | 'done', …)`
- Added missing type for `cds.test.log`
- Added missing `.ref` in CQN queries
- Added missing `.forUpdate`, `.forShareLock`, and `.search` in `cqn.SELECT`
- Calling `SELECT.one('...').from(Plural)` now properly returns a single instance


## Version 0.7.0 - 24-10-24

### Fixed
Expand Down
6 changes: 5 additions & 1 deletion apis/cqn.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ export type SELECT = { SELECT: {
columns?: column_expr[],
excluding?: string[],
where?: predicate,
having?: predicate,
groupBy?: expr[],
having?: predicate,
orderBy?: ordering_term[],
limit?: { rows: val, offset: val },
forUpdate?: { wait: number },
forShareLock?: { wait: number },
search?: predicate,
count?: boolean,
}, }

export type INSERT = { INSERT: {
Expand Down
5 changes: 5 additions & 0 deletions test/typescript/apis/project/cds-cqn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import cds from '@sap/cds'
import { testType } from './dummy'

// we just access expected properties without doing anything with them to see if they are present
// as expected. To apease the linter, we assign them to a variable.
Expand All @@ -24,6 +25,10 @@ res = sqn.SELECT.groupBy
res = sqn.SELECT.orderBy
res = sqn.SELECT.limit
res = sqn.SELECT.mixin
res = sqn.SELECT.forShareLock?.wait
res = sqn.SELECT.forUpdate?.wait
res = sqn.SELECT.search?.at(0)
testType<boolean | undefined>(sqn.SELECT.count)

// Runtime only...
let q = SELECT.from('Foo')
Expand Down
3 changes: 3 additions & 0 deletions test/typescript/apis/project/dummy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ export const attach = <T>(x?: T): T => x as T

// wrapper to get rid of all the "undefined as unknown as Foo"
export const as = <T>() => undefined as unknown as T

// test utility to replace "const x: T = foo()" with "testType<T>(foo())"
export const testType = <T>(x: T) => {}

0 comments on commit 29cbcd7

Please sign in to comment.