Skip to content

Commit

Permalink
Using UPSERTs in init.js
Browse files Browse the repository at this point in the history
  • Loading branch information
danjoa committed Jun 30, 2023
1 parent 8ffa3f0 commit 60a0ea5
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions bookshop/db/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,14 @@
* currencies, if not obtained through @capire/common.
*/

module.exports = async (tx)=>{

const has_common = tx.model.definitions['sap.common.Currencies']?.elements.numcode
if (has_common) return

const already_filled = await tx.exists('sap.common.Currencies',{code:'EUR'})
if (already_filled) return

await tx.run (INSERT.into ('sap.common.Currencies') .columns (
module.exports = async ()=>{

This comment has been minimized.

Copy link
@bugwelle

bugwelle Jul 3, 2023

Contributor

This commit seems to fail in combination with the latest CAP 7 versions (SAP internal GitHub repositories). I tested it locally with your all-in-one setup and reverting this commit makes our CI pass again.

Log using this commit:

 PASS  cap/samples/test/cds.ql.test.js
 PASS  cap/samples/test/hierarchical-data.test.js
 PASS  cap/samples/test/hello-world.test.js (5.718 s)
 PASS  cap/samples/test/messaging.test.js (5.97 s)
 FAIL  cap/samples/test/localized-data/services.test.js (6.293 s)
  ● cap/samples - Localized Data › serves localized $metadata documents

    ENTITY_ALREADY_EXISTS



  ● cap/samples - Localized Data › supports accept-language header

    ENTITY_ALREADY_EXISTS



  ● cap/samples - Localized Data › supports queries with $expand

    ENTITY_ALREADY_EXISTS



  ● cap/samples - Localized Data › supports queries with nested $expand

    ENTITY_ALREADY_EXISTS



  ● cap/samples - Localized Data › supports @cds.localized:false

    ENTITY_ALREADY_EXISTS



 PASS  cap/samples/test/consuming-services.test.js (6.622 s)
 PASS  cap/samples/test/odata.test.js (6.627 s)
 PASS  cap/samples/test/custom-handlers.test.js (6.718 s)
 PASS  cap/samples/test/fiori.test.js (7.042 s)

Test Suites: 1 failed, 8 passed, 9 total
Tests:       5 failed, 67 passed, 72 total
Snapshots:   0 total
Time:        7.461 s

This comment has been minimized.

Copy link
@johannes-vogel

johannes-vogel Jul 3, 2023

Contributor

I just had a look as well:

It seems the order during deployment is:

  1. local csv files -> use INSERT
  2. local init.js -> uses UPSERT
  3. csv files of common files -> uses INSERT

I think we either need to

  • change the order of data deployment
  • use UPSERT throughout this test
  • revert the change

This comment has been minimized.

Copy link
@johannes-vogel

johannes-vogel Jul 3, 2023

Contributor

#535 → for allowing us to continue

await UPSERT.into ('sap.common.Currencies') .columns (
[ 'code', 'symbol', 'name' ]
) .rows (
[ 'EUR', '€', 'Euro' ],
[ 'USD', '$', 'US Dollar' ],
[ 'GBP', '£', 'British Pound' ],
[ 'ILS', '₪', 'Shekel' ],
[ 'JPY', '¥', 'Yen' ],
))
)
}

0 comments on commit 60a0ea5

Please sign in to comment.