Collection validation should check `field` property of composite attributes
Opened this issue · 0 comments
raryanpur commented
Describe the bug
When defining a collection, ElectroDB validates composite attributes without checking the field
property. Since collections map to DynamoDB queries, and composite key attributes are mapped to DynamoDB names using the field
property if it's specified, the collection validator should take this property into account.
ElectroDB Version
2.14.1
ElectroDB Playground Link
N/A
Entity/Service Definitions
Include your entity model (or a model that sufficiently recreates your issue) to help troubleshoot.
{
model: {
entity: "restaurant",
service: "app",
version: "1"
},
attributes: {
id: {
type: "string"
field: "restaurantId"
},
name: {
type: "string"
}
},
indexes: {
record: {
collection: "patrons"
pk: {
field: "pk",
composite: ["id"],
},
sk: {
field: "sk",
composite: ["name"],
},
}
}
}
{
model: {
entity: "customer",
service: "app",
version: "1"
},
attributes: {
restaurantId: {
type: "string"
},
name: {
type: "string"
}
},
indexes: {
record: {
collection: "patrons"
pk: {
field: "pk",
composite: ["restaurantId"],
},
sk: {
field: "sk",
composite: ["name"],
},
}
}
}
Expected behavior
The collections schema validator should check the field
property during schema validation and the above should succeed.
Errors
ref: {
code: 1013,
section: 'join',
name: 'InvalidJoin',
sym: Symbol(error-code)
},