Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: post processing with custom join #480

Merged
merged 7 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions test/compliance/SELECT.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,23 @@ describe('SELECT', () => {
assert.strictEqual(res.length, 3, 'Ensure that all rows are coming back')
})

test('join', async () => {
const res = await cds.run(CQL`
SELECT A.bool
FROM basic.projection.globals as A
LEFT JOIN basic.projection.globals AS B
ON A.bool=B.bool`)
assert.strictEqual(res.length, 3, 'Ensure that all rows are coming back')
for (let i = 0; i < res.length; i++) {
const val = res[i].bool
if (typeof val === 'object') {
assert.strictEqual(val, null)
} else {
assert.strictEqual(typeof val, 'boolean')
}
}
})

test('statics', async () => {
const res = await cds.run(CQL`
SELECT
Expand Down Expand Up @@ -102,7 +119,7 @@ describe('SELECT', () => {
'func' as function : cds.String
FROM basic.projection.globals
`
cqn.SELECT.columns[0].val = function () {}
cqn.SELECT.columns[0].val = function () { }

await assert.rejects(cds.run(cqn))
})
Expand Down Expand Up @@ -164,7 +181,7 @@ describe('SELECT', () => {
const cqn = {
SELECT: {
from: { ref: ['complex.Authors'] },
columns: [{ ref: ['ID']}, { ref: ['name']}, { ref: ['books'], expand: ['*', ...nulls(197)]}]
columns: [{ ref: ['ID'] }, { ref: ['name'] }, { ref: ['books'], expand: ['*', ...nulls(197)] }]
},
}

Expand All @@ -178,7 +195,7 @@ describe('SELECT', () => {
const cqn = {
SELECT: {
from: { ref: ['complex.Books'] },
columns: [{ ref: ['ID']}, { ref: ['title']}, { ref: ['author'], expand: ['*', ...nulls(198)]}]
columns: [{ ref: ['ID'] }, { ref: ['title'] }, { ref: ['author'], expand: ['*', ...nulls(198)] }]
},
}

Expand Down Expand Up @@ -224,7 +241,7 @@ describe('SELECT', () => {
test('compare with DateTime column', async () => {
const entity = `basic.literals.dateTime`
const dateTime = '1970-02-02T10:09:34Z'
const timestamp = dateTime.slice(0,-1) + '.000Z'
const timestamp = dateTime.slice(0, -1) + '.000Z'
await DELETE.from(entity)
await INSERT({ dateTime }).into(entity)
const dateTimeMatches = await SELECT('dateTime').from(entity).where(`dateTime = `, dateTime)
Expand Down Expand Up @@ -316,7 +333,7 @@ describe('SELECT', () => {
query.SELECT.count = true
const result = await query
assert.strictEqual(result.$count, 1)
const renamed = result.map(row => ({key: row.ID, fullName: row.name}))
const renamed = result.map(row => ({ key: row.ID, fullName: row.name }))
assert.strictEqual(renamed.$count, 1)
})
})
Expand Down
1 change: 1 addition & 0 deletions test/scenarios/bookshop/read.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,5 @@ describe('Bookshop - Read', () => {
const res = await DELETE('/admin/Books(271)', admin)
expect(res.status).to.be.eq(204)
})

})