I am trying to push a schema with these two functions in it to my local docker image (running 5.4.0):
function getRoomFieldsForRoom(room){
room {
_id: .id,
roomTitle,
status
}
}
@role('server')
function createMonthlyPropertyRoomWithSubitemWrapper(payload) {
let room = {
id: '23233',
roomTitle: 'Room 1',
status: 'VACANT'
}
getRoomFieldsForRoom(room)
}
And I get the following error:
error: Command failed: yarn fauna schema push --dir scripts/faunax/schema --secret ***** --url=http://localhost:8443 --force
› Error: java.lang.RuntimeException: Unimplemented Please create a ticket at
› https://support.fauna.com
error Command failed with exit code 1.
It seems like doing projection on room
in the getRoomFieldsForRoom
function is what causes the schema push to fail.
For some reason this workaround works:
function getRoomFieldsForRoom(room){
let room: any = room
room {
_id: .id,
roomTitle,
status
}
}
@role('server')
function createMonthlyPropertyRoomWithSubitemWrapper(payload) {
let room = {
id: '23233',
roomTitle: 'Room 1',
status: 'VACANT'
}
getRoomFieldsForRoom(room)
}
So that workaround solved the issue for the minimal reproduction I pasted above, but not for the full version of my functions. When I tried to use the workaround, I got this error:
› Error: Invalid database schema update.
› error: Value cannot be constrained by inner generic type `any`
› at *getRoomFieldsForRoom.body*:41:7
› |
› 41 | let room: any = room
› | ^^^^
› |
› hint: Generic type definition
› |
› 41 | let room: any = room
› | ^^^
› |
› hint: Outer value originates here
› at *getRoomFieldsForRoom.body*:1:2
› |
› 1 | (room) => {
› | ^^^^
› |
But when I tried a different workaround, it worked:
Object.assign({}, room) {
_id: .id,
roomTitle,
status
}
Another update. My Object.assign
workaround breaks if I attempt to project the subfields of one of the top level fields. So doing this triggers the original java.lang.RuntimeException: Unimplemented
error:
Object.assign({}, room) {
_id: .id,
roomTitle,
status,
vacancy {
targetRent
}
}
I’ve highlighted this issue with our engineers, and we’re tracking internally now.
Instead of specifying Any
as the type for room
does specifying an object with { *: Any }
?
function getRoomFieldsForRoom(room: { *: Any}): {*: Any} {
room {
_id: .id,
roomTitle,
status
}
}
or similar to your original workaround?
function getRoomFieldsForRoom(room) {
let room: { *: Any} = room
room {
_id: .id,
roomTitle,
status
}
}
I ran into this issue again in another part of my code.
Using a simple Any
like this was enough to get around the issue:
function projectMessage(message: Any): Any