Skip to content

Commit

Permalink
apiRequireId returns 403 when using in Statement #290
Browse files Browse the repository at this point in the history
  • Loading branch information
noam-honig committed Nov 17, 2023
1 parent e4a5dc3 commit ef8f71e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -27,6 +27,7 @@ All notable changes to this project will be documented in this file.
- Fixed issue with sort result after live query
- Fix issue with compound id on middleware based servers
- Added with remult for sveltekit for usage before the remult hook
- Fixed issue with requireId not respecting in statement #290

## [0.22.9] 2023-10-06

Expand Down
4 changes: 3 additions & 1 deletion projects/core/src/data-api.ts
Expand Up @@ -136,7 +136,9 @@ export class DataApi<T = any> {
databaseCustom: () => {},
isGreaterOrEqualTo: () => {},
isGreaterThan: () => {},
isIn: () => {},
isIn: (col) => {
if (this.repository.metadata.idMetadata.isIdField(col)) hasId = true
},
isLessOrEqualTo: () => {},
isLessThan: () => {},
isNotNull: () => {},
Expand Down
3 changes: 3 additions & 0 deletions projects/core/src/remult3/remult3.ts
Expand Up @@ -721,3 +721,6 @@ remult.apiClient.url='localhost:3007/api
*/
//p1 - with remult promise for remultexpress
//p1 - 'update tasks set where id = $1
//p1 - live query refresh of view on table update
27 changes: 27 additions & 0 deletions projects/tests/tests/basicRowFunctionality.spec.ts
Expand Up @@ -1261,6 +1261,33 @@ describe('data api', () => {
await api.get(t, 1)
d.test()
})
it.only('apiRequireId in', async () => {
let type = class extends newCategories {}
Entity('', {
apiRequireId: true,
})(type)
let [c, remult] = await createData(async (i) => {
await i(1, 'noam', 'a')
await i(2, 'yael', 'b')
await i(3, 'yoni', 'a')
}, type)

var api = new DataApi(c, remult)

var t = new TestDataApiResponse()
var d = new Done()
t.success = (result) => {
expect(result.length).toBe(2)
d.ok()
}
await api.getArray(t, {
get: (x) => {
if (x == 'id.in') return ['1', '2']
return undefined
},
})
d.test()
})
it('delete id not Allowed for specific row', async () => {
let type = class extends newCategories {}
Entity<typeof type.prototype>('', {
Expand Down

0 comments on commit ef8f71e

Please sign in to comment.