SeaQL / sea-orm

🐚 An async & dynamic ORM for Rust
https://www.sea-ql.org/SeaORM/
Apache License 2.0
7.03k stars 493 forks source link

Allow dynamic `schema_name`s #2110

Open xervon opened 7 months ago

xervon commented 7 months ago

PR Info

I'd like to be able to switch schema_names at runtime to switch between development and production environments.

This PR changes the schema_name parameter of the DeriveEntityModel and DeriveEntity macros to take a syn::Expr instead of a syn::Lit. As far as I can tell this shouldn't break any existing code.

Since I haven't done much work with derive macros before, I couldn't quite tell how to integrate the change into the test suite. I'd appreciate hints on how to add them.

New Features

tyt2y3 commented 7 months ago

Thanks for the contribution. Can you add some tests illustrating the behaviour you wanted to achieve? i.e.

schema_name parameter of the DeriveEntityModel and DeriveEntity macros to take a syn::Expr