Comments (7)
I got you. The DeriveIden macro comes from SeaQuery's Iden macro, so it has to match the behaviour for backwards compatibility reasons.
I think we can 1) remove it in all examples and use Alias::new
instead or 2) design a new macro for a specific purpose or 3) add one more special case (which might be more confusing) or 4) use unit struct instead i.e DeriveIden
on struct Something;
which has no special treatment
Can you share the pieces of code you end up with, so we can brainstorm how to make it more concise?
from sea-orm.
Thank you for the feedback. The blog post https://cprimozic.net/notes/posts/trying-out-sea-orm/ is definitely insightful, and we will be able to improve on a few of the problems.
I have addressed some of the confusion by editing the doc https://www.sea-ql.org/SeaORM/docs/generate-entity/enumeration/#native-database-enum and https://www.sea-ql.org/SeaORM/docs/migration/writing-migration/#seaquery
If you have more suggestions, just let us know!
from sea-orm.
Wow, that was incredibly fast. Thanks so much for your hard work @tyt2y3
from sea-orm.
Referencing this commit
Another major issue with this approach is that you're unable to use this enum to add entries to the database. Simply put, if the enum is declared using DeriveIden
alone, then one can't use
this enum to populate the database in a later migration, unless you impl
something simliar to as_enum as impl Into<SimpleExpr> for Tea
method yourself. That being the case it seems better that the primary example for adding a Postgres enum should use DeriveActiveEnum
, unless there's some issue that I'm not aware of with that approach.
Here are the two approaches:
// InsertStatement
.values_panic([
// ...some other column values
// ⚠ This needs to be implemented if only using DeriveIden
Tea::BreakfastTea.into(),
// This is provided by DeriveActiveEnum
Tea::BreakfastTea.as_enum(),
])
from sea-orm.
Not sure if that's been mentioned, but using the create_enum_from_active_enum helper function is probably the easiest way.
from sea-orm.
Not sure if that's been mentioned, but using the create_enum_from_active_enum helper function is probably the easiest way.
Just a suggestion: If that's the recommended way, maybe it would be best to have that be the first example here and also have it link to an example. Examples maybe should also include examples of using the enum to populate data in a migration using Tea::BreakfastTea.as_enum()
.
from sea-orm.
Can you open a PR on https://github.com/SeaQL/seaql.github.io/ ?
from sea-orm.
Related Issues (20)
- sea-orm-migration - Compile error using most recent version of rc2 HOT 12
- Missing downward feature `runtime-tokio`. HOT 4
- Mock Auto Increment ID Not Working for Postgres Backend Complaining About Null HOT 1
- sea-orm-cli generate error HOT 1
- .money_len type creates invalid SQL HOT 1
- Compilation error when building with sqlx-sqlite and runtime-async-std-rustls HOT 3
- is Sea orm Json type can't insert text [] type HOT 2
- Migration fresh command cannot drop types with Postgresql
- Clarification on Relationship Generation in sea-orm-cli Based on ForeignKey Constraints
- `find_with_related` implicitly adds ordering on `left.id` HOT 3
- In migration use enumeration
- Expose `order_by_with_nulls` in `QueryOrder` trait HOT 3
- Alter enum column with new type (missing USING)
- sea-orm-cli hard codes schema
- Syntax error when including parenthesis in SeaORM HOT 1
- Calling multiple deletes_many results in an additional 100MB of memory without decreasing it
- serde rename_all not working correctly on ActiveModel HOT 2
- Cursor on joined table
- Cannot use column in a like expression
- sea-orm-cli cannot open SQLite db. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sea-orm.