diff --git a/db-service/lib/cqn2sql.js b/db-service/lib/cqn2sql.js index ba6ca43c1..37472c8b7 100644 --- a/db-service/lib/cqn2sql.js +++ b/db-service/lib/cqn2sql.js @@ -749,8 +749,9 @@ class CQN2SQLRenderer { if (_with) _add(_with, x => this.expr(x)) function _add(data, sql4) { for (let c in data) { - if (!elements || (c in elements && !elements[c].virtual)) { - if (cds.unfold && elements?.[c].is_struct) continue // skip structs from universal csn + const columnExistsInDatabase = + elements && c in elements && !elements[c].virtual && !elements[c].isAssociation && !elements[c].value + if (!elements || columnExistsInDatabase) { columns.push({ name: c, sql: sql4(data[c]) }) } } diff --git a/test/bookshop/db/data/sap.capire.bookshop-Authors.csv b/test/bookshop/db/data/sap.capire.bookshop-Authors.csv index f97bfeed4..f07c970e1 100644 --- a/test/bookshop/db/data/sap.capire.bookshop-Authors.csv +++ b/test/bookshop/db/data/sap.capire.bookshop-Authors.csv @@ -1,5 +1,5 @@ -ID;name;dateOfBirth;placeOfBirth;dateOfDeath;placeOfDeath -101;Emily Brontë;1818-07-30;Thornton, Yorkshire;1848-12-19;Haworth, Yorkshire -107;Charlotte Brontë;1818-04-21;Thornton, Yorkshire;1855-03-31;Haworth, Yorkshire -150;Edgar Allen Poe;1809-01-19;Boston, Massachusetts;1849-10-07;Baltimore, Maryland -170;Richard Carpenter;1929-08-14;King’s Lynn, Norfolk;2012-02-26;Hertfordshire, England \ No newline at end of file +ID;name;dateOfBirth;placeOfBirth;dateOfDeath;placeOfDeath; city; street; +101;Emily Brontë;1818-07-30;Thornton, Yorkshire;1848-12-19;Haworth, Yorkshire; Bradford; 1 Main Street +107;Charlotte Brontë;1818-04-21;Thornton, Yorkshire;1855-03-31;Haworth, Yorkshire; Bradford; 2 Main Street +150;Edgar Allen Poe;1809-01-19;Boston, Massachusetts;1849-10-07;Baltimore, Maryland; Baltimore; 1 Main Street +170;Richard Carpenter;1929-08-14;King’s Lynn, Norfolk;2012-02-26;Hertfordshire, England; London; 1 Main Street \ No newline at end of file diff --git a/test/bookshop/db/schema.cds b/test/bookshop/db/schema.cds index f2871438e..b5f3cb7fd 100644 --- a/test/bookshop/db/schema.cds +++ b/test/bookshop/db/schema.cds @@ -12,6 +12,8 @@ entity Books : managed { currency : Currency; image : LargeBinary @Core.MediaType : 'image/png'; footnotes: array of String; + + authorsAddress: String = author.address; } entity Authors : managed { @@ -22,6 +24,10 @@ entity Authors : managed { placeOfBirth : String; placeOfDeath : String; books : Association to many Books on books.author = $self; + + street: String; + city: String; + address: String = street || ', ' || city; } /** Hierarchically organized Code List for Genres */