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

ValueTrait for SQLx #477

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

ValueTrait for SQLx #477

wants to merge 3 commits into from

Conversation

tyt2y3
Copy link
Member

@tyt2y3 tyt2y3 commented Oct 16, 2022

This is an initial design of ValueTrait to allow custom Value to be used with SeaQuery.

The tricky part is the dependency tree:

sea-query-binder v0.1.0 (/home/chris/sea-query/sea-query-binder)
├── sea-query v0.27.0 (/home/chris/sea-query)
│   ├── sea-query-derive v0.2.0 (proc-macro) (/home/chris/sea-query/sea-query-derive)
│   └── sea-query-sqlx v0.1.0 (/home/chris/sea-query/sea-query-sqlx)
│       └── sqlx v0.6.2
│           ├── sqlx-core v0.6.2
│           │   ├── sqlx-rt v0.6.2
│           └── sqlx-macros v0.6.2 (proc-macro)
│               ├── sqlx-core v0.6.2
│               │   ├── sqlx-rt v0.6.2 (*)
│               ├── sqlx-rt v0.6.2 (*)
├── sea-query-sqlx v0.1.0 (/home/chris/sea-query/sea-query-sqlx) (*)
└── sqlx v0.6.2 (*)

Now sadly we can no longer cargo b --all-features.

@tyt2y3
Copy link
Member Author

tyt2y3 commented Oct 16, 2022

Would appreciate some thoughts @ikrivosheev @billy1624

Copy link
Member

@billy1624 billy1624 left a comment

Choose a reason for hiding this comment

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

Oh no, sorry for the delay. My GitHub notification box is flooded.

I think we still need:

  • impl SqlxValueTrait for xxx, e.g. i32, Vec<i32>...etc.
  • impl<T: SqlxValueTrait> From<T> for Value: I doubt this will cause compile error.

For i32, we have following two impl From<i32> for Value:

  • impl From<i32> for Value
  • impl SqlxValueTrait for i32
    • Hence, impl<T: SqlxValueTrait> From<T> for Value valid for i32 as well.

Will Rust compiler compliant?

@tyt2y3
Copy link
Member Author

tyt2y3 commented Nov 15, 2022

My plan is, we keep using our current implementation for all supported types, i32 etc.
So we don't need to blanket impl anything.

@billy1624
Copy link
Member

Okay, so the burden is on the user who need to convert the types into SeaRc<dyn SqlxValueTrait>

@tyt2y3
Copy link
Member Author

tyt2y3 commented Nov 15, 2022

Okay, so the burden is on the user who need to convert the types into SeaRc<dyn SqlxValueTrait>

Yes. A hard-way is better than no-way.

@tyt2y3 tyt2y3 marked this pull request as draft December 9, 2022 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Triage
Development

Successfully merging this pull request may close these issues.

2 participants