Comments (3)
hi, thanks for the detailed issue report!
and given that CAP encourages domain-driven modelling (just like what you did with
notifications: array of {
description: String;
frequency: Integer enum {
daily = 1;
weekly = 2;
monthly = 3;
}
}
instead of putting this in a relation e.g. via association of
),
i think it's not just a rare case, but a pending issue we need to address.
could you bake a test case into code?
i would see the cds-runtime/-ql related test in https://github.com/sapmentors/cds-pg/blob/main/__tests__/lib/pg/ql.test.js
where you could load a dedicated model à la (watch out, pidgeon code)
test('load array model prop', async () => {
await deploy(yourModel, {}).to(this._dbProperties)
const { Setting } = cds.entities('your.name.space')
const setting = await cds.run(INSERT.into(...).entries([{
"id": 2,
"tempThreshold": "10.1",
"notifications": [{
"description": "New settings",
"frequency": 1,
"message": "String"
}]
}]
expect(setting.affectedRows).toStrictEqual(1)
const singleSetting = await cds.run(SELECT.one(Setting).where({ id: '2 }))
expect(singleSetting).toHaveProperty('notifications', ...)
})
and the related OData-related test (POST
with payload) in https://github.com/sapmentors/cds-pg/blob/main/__tests__/lib/pg/service.test.js
- could deploy your custom model similar to
cds-pg/__tests__/lib/pg/service.test.js
Line 77 in 3691882
- select your inserted data similar to
cds-pg/__tests__/lib/pg/service.test.js
Line 105 in 3691882
this would make it way easier to both locate the origin of the bug and be closer to the domain-modelling idea of CAP also with PostgreSQL!
from cds-pg.
Ok looks like I've managed the first part.
test('load array model prop', async () => {
await deploy('./arraymodel.cds', {}).to(this._dbProperties)
const { Settings } = cds.entities('arraymodel')
const setting = await cds.run(INSERT.into(Settings).entries([{
"id": 2,
"tempThreshold": "10.1",
"notifications": [{
"description": "New settings",
"frequency": 1,
"message": "String"
}]
}]))
expect(setting.affectedRows).toStrictEqual(1)
const singleSetting = await cds.run(SELECT.one(Settings).where({ id: 2 }))
expect(singleSetting).toHaveProperty('notifications', '[{"description": "New settings","frequency": 1,"message": "String"}]')
})
here is a content of arraymodel.cds file:
namespace arraymodel;
service settingsService {
entity Settings {
key id: Integer;
tempThreshold: Decimal(3,1) not null;
Notifications: Array of {
description: String;
frequency: Integer enum {
daily = 1;
weekly = 2;
monthly = 3;
};
message: String;
}
}
}
I'm new to the JS testing frameworks, so I might misunderstand the process (
from cds-pg.
cool, things start coming together!
the test looks fine!
hint 1: use test.only
to ... well ... only run that one test when you issue npm run test -- <testfilename>
hint 2: please find much more detail about the test- and dev-env setup in https://github.com/sapmentors/cds-pg/blob/main/docs/CONTRIBUTING.md#runnable-queries-and-runtime-debug-capabilites
looking fwd to the odata-level test, then we have something to work in the array of
feature in postgres!
from cds-pg.
Related Issues (20)
- Invalid SQL query when Draft Entity make reference to other Draft Entity in OData call. HOT 3
- Vulnerability in momentjs 2.9.1 HOT 3
- Error upon modifying view in service HOT 1
- Strong security issue regarding indirect dependency to jsonwebtoken npm-module 8.x
- PATCH is executed on active entity for drafts with compositions HOT 3
- Error: [cds-dbm] - failed to load model undefined (STDERR, APP/TASK/deploy-to-postgresql)# HOT 2
- TypeError: Cannot read properties of undefined (reading 'definitions') HOT 4
- connection closed after each query
- Date conversion interprets timezone incorrectly
- Get request on entity not working
- Retain Column Name as case sensitive during deployment
- Wrong type cast of boolean HOT 1
- Query draft entities on db layer
- broken connectivity in 0.1.36 when using "cds watch" instead of "cds serve". using cap cds 6.6
- error: relation "[tablename]" does not exist
- duplicate key entry HOT 2
- cds-pg deploy fails with "Cannot find module '@sap/cds/lib/deploy'"
- Initial Release schedule?
- ERROR: syntax error at or near "LOCK" at character - STATEMENT: SELECT 1 FROM My_Type ALIAS_1 WHERE ( code = 1 ) LIMIT 1 FOR SHARE LOCK
- Query values must be an array ERROR
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cds-pg.