-
-
Notifications
You must be signed in to change notification settings - Fork 523
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
Design and implement the Bakery Chain schema #34
Conversation
Thank you. Seems good so far. One thing. We can use db.get_query_builder_backend() in place of |
Can you paste the latest ER diagram here again? |
One problem. Isn't the many side of the Cake - LineItem relation in the wrong place? |
Yes, I see what you mean. I started looking at Cake as a unique product when I added the 'best before', 'produced at' etc fields. |
Maybe the date/timestamp fields can go on the lineitem |
We might switch to |
pub total: f32, | ||
pub bakery_id: Option<i32>, | ||
pub customer_id: Option<i32>, | ||
pub placed_at: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use sea_query's NaiveDateTime support on timestamp.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tyt2y3 when I use NaiveDateTime from chrono
pub placed_at: NaiveDateTime,
I get the following errors about the trait bounds not satisfied:
Compiling sea-orm v0.1.0 (/Users/sam/Code/github/sea-orm)
error[E0277]: the trait bound `NaiveDateTime: std::default::Default` is not satisfied
--> tests/bakery_chain/order.rs:20:48
|
20 | #[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel)]
| ^^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `NaiveDateTime`
|
::: /Users/sam/Code/github/sea-orm/src/entity/active_model.rs:10:22
|
10 | V: Into<Value> + Default,
| ------- required by this bound in `ActiveValue`
|
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.
error: could not compile `sea-orm`
To learn more, run the command again with --verbose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
732428f
I removed the Default
bound from the trait ActiveValue
Should be okay now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tyt2y3 it's getting further now but there are still some issues. Please see the this branch: https://github.com/SeaQL/sea-orm/tree/nativedatetime
and test using:
cargo test --test bakery_chain_tests -- --nocapture
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need help on this? Or you can learn from what I did on Decimal support?
Thank you. Looks fine so far. Please continue. But I also want to use more data types of 'sea_query::Value' so as to make the coverage more complete. |
Nice. Have you tried running it against a MySQL instance? |
SeaQL/sea-query#67 |
With regards to using Decimal for our prices, would our model look something like this:
If so where is
Or do we just use |
Sorry I forgot to impl that trait. |
I have fixed the build errors. |
Nice. I am glad we made it work now! |
Thank you! |
How about NaiveDateTime, are you also trying? |
@tyt2y3 I was getting this:
So I've made placed_at: |
okay so, I think the problem is you merged wrongly. |
It should be fine if we branch off again from master and add in NaiveDateTime now. |
Sqlite schema discovery
This PR implements the example schema for the entities in the Bakery Chain domain and adds basic tests for the creation of these tables.