Closed dragolea closed 5 months ago
Hi Daniel,
no, this does not look like it is intended. But it looks like it belongs in cds-types instead, no? Or did the structure of the action, generated by cds-typer, change to cause this new behaviour?
Best, Daniel
Looks like the cds-typer
caused this issue, version 0.19.0 has a totally different structure than 0.20.0.
In the example below the format field
should not point to the Entity itself, but to the entity field
which can be (number, string, undefined ...)
Could you please attach a minimal sample model in which I can observe this behaviour?
Sure, Below we have the CDS structure
// Unbound action
action changeBookProperties(format : BookFormats:format, language : BookFormats:language) returns {
language : String;
format : BookFormats:format
};
// Unbound action
action submitOrder(book : Books:ID, quantity : Integer) returns {
stock : Integer
};
// Unbound function
function submitOrderFunction(book : Books:ID, quantity : Integer) returns {
stock : Integer
};
Below we have a CDS Typer TS generated entity
export declare const changeBookProperties: { (format: BookFormat | null, language: BookFormat | null): {
language?: string | null,
format?: __.DeepRequired<BookFormat>['format'] | null,
} | null | null, __parameters: {format: BookFormat | null, language: BookFormat | null}, __returns: {
language?: string | null,
format?: __.DeepRequired<BookFormat>['format'] | null,
} | null | null, kind: 'action'};
export declare const submitOrder: { (book: Book | null, quantity: number | null): {
stock?: number | null,
} | null | null, __parameters: {book: Book | null, quantity: number | null}, __returns: {
stock?: number | null,
} | null | null, kind: 'action'};
export declare const submitOrderFunction: { (book: Book | null, quantity: number | null): {
stock?: number | null,
} | null | null, __parameters: {book: Book | null, quantity: number | null}, __returns: {
stock?: number | null,
} | null | null, kind: 'function'};
Thanks for the model so far! I'm afraid it is not self-contained/ minimal, as it refers to BookFormats
and Books
, which are not included in the model, so I can not reproduce the issue on my end. Could you please extend the sample to be self-contained?
Sure,
Just a summary and a helping hand :
entity BookFormats : managed {
key ID : Integer;
format : String(50);
price : Decimal @mandatory;
pages : Integer @mandatory;
language : String(50);
publicationDate : Date;
// Associations
book : Association to Books;
}
entity Books : managed {
key ID : Integer;
title : localized String(111) @mandatory;
descr : localized String(1111);
stock : Integer;
price : Decimal;
currency : Currency;
image : LargeBinary @Core.MediaType: 'image/png';
// Associations
author : Association to Authors @mandatory;
genre : Association to Genres;
reviews : Association to many Reviews
on reviews.book = $self;
stats : Association to one BookStats
on stats.book = $self;
bookFormats : Association to many BookFormats
on bookFormats.book = $self;
bookRecomanddations : Association to many BookRecommendations
on bookRecomanddations.book = $self;
}
Hi Daniel,
I have prepared a fix which I will release later this day: https://github.com/cap-js/cds-typer/pull/227 Feel free to try it out beforehand on your model.
Best, Daniel
Question
Hi guys, Recently after updating to the latest CDS-Typer, I've seen that the action now has a different structure than before.
New version, the req contains a new property ID which points to the Entity, this means you will have to write
or
this means that that you will always have to say to all properties
Previously in the past version was like :