Skip to content

[BUG] CQN predicates expect wrong types #32

@siarhei-murkou

Description

@siarhei-murkou

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Example:

import cqn from "@cap-js/cds-types";

const condition_1: cqn.predicate = [{ ref: ["prop_1"] }, "is", null];
const condition_2: cqn.predicate = [{ ref: ["prop_2"] }, "in", { val: ["val_1", "val_2"] }];

It leads to:

TS2322: Type { ref: string[]; } is not assignable to type
    Partial<string & ref & val & xpr & function_call & SELECT>
        Types of property valueOf are incompatible.
            Type () => Object is not assignable to type (() => string) & (() => Object)
                Type () => Object is not assignable to type () => string
                    Type Object is not assignable to type string

Expected Behavior

No TypeScript issues.

References

No references.

Versions

@cap-js/cds-typer: 0.15.0
@cap-js/sqlite: 1.2.1
@sap/cds: 7.5.3
@sap/cds-compiler: 4.0.2
@sap/cds-dk: 7.5.1
@sap/cds-dk (global): 7.3.1
@sap/cds-fiori: 1.1.0
@sap/cds-foss: 4.0.2
@sap/cds-mtxs: 1.14.2
@sap/eslint-plugin-cds: 2.6.4
Node.js: v18.18.2

Anything else? Logs?

As I got, the issue is due to this line:

export type predicate = UnionsToIntersections<_xpr>

Which is incorrect, because this intersection allows only string-like values. I suppose the value should be _xpr as it was defined in past.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions