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

Collection validation should check field property of composite attributes #394

Open
raryanpur opened this issue Jun 17, 2024 · 0 comments
Open

Comments

@raryanpur
Copy link

raryanpur commented Jun 17, 2024

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)
},

@raryanpur raryanpur changed the title Collection validation should respect field property of attributes Collection validation should respect field property of composite attributes Jun 17, 2024
@raryanpur raryanpur changed the title Collection validation should respect field property of composite attributes Collection validation should check field property of composite attributes Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant