cap-js / cds-types

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

fix: fixes issues in ql SELECT.from(...) when using typer classes #268

Closed stockbal closed 1 week ago

stockbal commented 1 month ago

This PR addresses the following issues

Sample schema

// model.cds
entity Books {
  key ID    : Integer;
      title : String;
}

Generated classes from cds-typer

class Book { }
class Books extends Array<Book> {}

Issues

~1) No compiler issues, but both queries actually return type any instead of Book~

let selectOne: Book

selectOne = await SELECT.from(Books, 42)
selectOne = await SELECT.from(Books, 42, (b: Book) => b.title)

2) Produces typescript issues because the plural type is the assumed result of the queries

let selectOne: Book

selectOne = await SELECT.from(Book, 42)
selectOne = await SELECT.from(Book, 42, ["title"])
selectOne = await SELECT.from(Book, 42, (b: Book) => f.x)
stockbal commented 1 month ago

Due to #201, Issue 1) no longer exists, and fix for issue 2) has been adjusted