cap-js / cds-types

Type definitions for CDS
Apache License 2.0
10 stars 10 forks source link

`SELECT.one(<string>)` returns PluralType #315

Open Akatuoro opened 1 day ago

Akatuoro commented 1 day ago

Is there an existing issue for this?

Current Behavior

When giving a string as argument or tagged templates, SELECT.one

const result = await SELECT.one('max(TravelID) as maxID') .from(Travel)
const result = await SELECT.one `max(TravelID) as maxID` .from(Travel)
// const result: PluralInstanceType<typeof Travel>

When using the entity as first argument (e.g. SELECT.one(Travel, t => t.TravelUUID) .where({ TravelID })), it correctly returns the Travel type.

Expected Behavior

const result = await SELECT.one `max(TravelID) as maxID` .from(Travel)
// const result: Travel

References

https://cap.cloud.sap/docs/node.js/cds-ql#one

Versions

@capire/sflight https://github.com/SAP-samples/cap-sflight
@cap-js/cds-typer 0.28.0
@cap-js/cds-types 0.7.0
@cap-js/db-service 1.11.0
@cap-js/hana 1.3.2
@cap-js/sqlite 1.7.4
@sap/cds 8.4.0
@sap/cds-compiler 5.2.0
@sap/cds-fiori 1.2.7
@sap/cds-foss 5.0.1
@sap/cds-mtxs 2.0.5
CAP Java SDK 3.3.1
Java 21.0.5
Maven 3.6.3
Node.js v22.7.0
OS Mac OS X, 14.6.1, arch: x86_64
Spring Boot 3.3.5
cds4j 3.3.1

Anything else? Logs?

No response