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

Add support for composite keys #103

Open
3 tasks
adamskt opened this issue Oct 17, 2018 · 4 comments
Open
3 tasks

Add support for composite keys #103

adamskt opened this issue Oct 17, 2018 · 4 comments

Comments

@adamskt
Copy link
Member

adamskt commented Oct 17, 2018

Because the ClassViewModel for model entities only takes the first property with IsPrimaryKey and additionally because the IsPrimaryKey property only looks for the KeyAttribute (ignoring anything set up in the fluent interface), composite keys aren't currently supported by the generated API controllers.

Stuff needed to support this.

  • Change ClassViewModel to have a collection of primary keys,
  • Change ApiController generator to generate anonymous types for key parameters when keys number more than one.
  • Change IsPrimaryKey impl to be aware of both fluently-defined keys and attributed ones.
@GrantErickson
Copy link
Collaborator

There are also several spots where the key is returned as a query string. We would need to figure this one out as well. Significant bit of work here. Not sure if the complexity is worth it rather than just adding a single primary key which some would hold is a good practice anyway.

@adamskt
Copy link
Member Author

adamskt commented Oct 18, 2018

I agree it's non-trivial and complex, but it would also enable the multi-tenant #5 story with SQL row-level security (i.e. a tenant_id field on every model).

@GrantErickson
Copy link
Collaborator

Yes, that is true. I think we could also have it along side a unique single column key. Which might be easier to generate keys for as well.

@ascott18
Copy link
Collaborator

Probably dependent on #266 to make the DX nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants