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

feat: implement very basic ORM #9

Merged
merged 1 commit into from
Aug 19, 2024
Merged

feat: implement very basic ORM #9

merged 1 commit into from
Aug 19, 2024

Conversation

m4tx
Copy link
Contributor

@m4tx m4tx commented Aug 17, 2024

At this stage, there is an easy way to query, insert, and delete with super simple filters. This is enough of a scaffolding to be able to quickly make it much more advanced.

@m4tx m4tx requested review from seqre and Iipin August 17, 2024 11:34
Copy link

codecov bot commented Aug 17, 2024

Codecov Report

Attention: Patch coverage is 85.77982% with 62 lines in your changes missing coverage. Please review.

Files Patch % Lines
examples/todo-list/src/main.rs 0.00% 30 Missing ⚠️
flareon/src/db.rs 91.58% 17 Missing ⚠️
flareon/src/db/query.rs 80.00% 9 Missing ⚠️
flareon-macros/src/lib.rs 77.77% 2 Missing ⚠️
flareon-macros/src/model.rs 98.43% 2 Missing ⚠️
flareon/src/request.rs 0.00% 1 Missing ⚠️
flareon/src/router/path.rs 80.00% 1 Missing ⚠️
Flag Coverage Δ
rust 61.86% <85.77%> (+11.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
flareon-admin/src/lib.rs 100.00% <ø> (ø)
flareon-auth/src/lib.rs 100.00% <ø> (ø)
flareon-macros/tests/compile_tests.rs 100.00% <100.00%> (ø)
flareon/src/db/fields.rs 100.00% <100.00%> (ø)
flareon/src/error.rs 0.00% <ø> (ø)
flareon/src/forms.rs 0.00% <ø> (ø)
flareon/src/lib.rs 0.00% <ø> (ø)
flareon/src/request.rs 0.00% <0.00%> (ø)
flareon/src/router/path.rs 90.47% <80.00%> (ø)
flareon-macros/src/lib.rs 90.90% <77.77%> (-9.10%) ⬇️
... and 4 more

Comment on lines +73 to +74
TodoItem::objects()
.filter(<TodoItem as Model>::Fields::ID.eq(todo_id))
Copy link
Contributor Author

@m4tx m4tx Aug 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually we'll have some nice macro that will turn the above into something like:

query!(TodoItem, col(id) == todo_id)

(or something similar)

but I wanted to keep this PR smaller (and honestly, the current API isn't terribly bad either).

Copy link
Contributor Author

@m4tx m4tx Aug 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed for now as the proc macros currently have the ORM source path hardcoded as ::flareon::db (and honestly I'm not sure about if there is an easy way to un-hardcode this). We might uncouple this eventually if it will make sense in the future, but let's keep the ORM bundled inside the main crate for now.

@m4tx m4tx force-pushed the orm-new branch 2 times, most recently from d8f5b41 to cdb8653 Compare August 18, 2024 12:27
Base automatically changed from todo-app to master August 19, 2024 14:13
At this stage, there is an easy way to query, insert, and delete with
super simple filters. This is enough of a scaffolding to be able to
quickly make it much more advanced.
@m4tx
Copy link
Contributor Author

m4tx commented Aug 19, 2024

Seems like the audit check failure is partially caused by a bug in Cargo: rust-lang/cargo#10801 (comment). A vulnerability was found in rsa package which is not used by as at the moment, but appears in Cargo.lock because it's an optional weak dependency.

The vulnerability in sqlx however is valid, but the fix hasn't been deployed yet. Merging this PR now; we'll update sqlx as soon as the fix is there.

@m4tx m4tx merged commit 88067d7 into master Aug 19, 2024
17 of 18 checks passed
@m4tx m4tx deleted the orm-new branch August 19, 2024 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant