-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat(orm): add foreign key support #88
Conversation
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.
Seems like a good start
I'm investigating the build failure, it builds successfully in current Rust beta and nightly... Wondering if rust-lang/rust#130654 might be the reason it's fixed. If I won't get anywhere, I would consider waiting two more days for Rust 1.84 to hit stable and just merge this as-is. We don't really care about this project working on old stable compiler versions anyways... (yet!) |
Ah yes, seems like indeed what I've linked is the fix for the issue. There's a blogpost about this: https://blog.rust-lang.org/inside-rust/2023/12/22/trait-system-refactor-initiative.html I think these trait impls are problematic: impl<T: DatabaseField> ToDbFieldValue for Auto<T> {}
impl<T: DatabaseField> ToDbFieldValue for Option<Auto<T>> {}
impl<T: Model + Send + Sync> ToDbFieldValue for ForeignKey<T> {}
impl<T: Model + Send + Sync> ToDbFieldValue for Option<ForeignKey<T>> {} (or some subset of them) I don't really want to remove them though, since they make implementing new DatabaseField types much easier (and it's nice to have shiny new features if we're writing a shiny new framework anyway — modern codebase will be one of our advantages over other similar projects). Like I said in my previous comment, I'd just wait for Rust 1.84 to hit stable (9 Jan, so we're almost there) and just run CI on beta until then. @seqre what do you think? |
c19c3c1
to
4f30fbe
Compare
d082bb1
to
a6cdd82
Compare
1.84 has been released today, so we're back on stable. |
I agree, since this is a new framework with no existing users, I see no point in supporting older compiler versions. Once it gains popularity, we can think about supporting N-X versions. |
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.
LGTM overall, some notes for possible improvements and nitpicks
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.
Great work!
This also contains a general ORM refactor:
Auto
enum was introduced instead of implying if a field is autoincrement based on its namesave()
now actually modifies the saved model with newly assigned autoincrement primary keys (if any)SELECT
query is performed afterINSERT
for MySQL to obtain the auto-generated values because MySQL doesn't support theRETURNING
clause.