-
-
Notifications
You must be signed in to change notification settings - Fork 242
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
Changed query methods to accept slices #1840
Changed query methods to accept slices #1840
Conversation
Converted to a draft to prevent an accidental merge before #1837. |
Thanks for this. It’s a good change. Looks like CI didn’t like it. |
This isn't something to address here, but a soundness problem with Spi is that query args are just Datums. We can't verify that the provided Datum is of a type that's compatible with the query argument position. let foo = Spi::get_one_with_args::<pg_sys::Oid>(
"SELECT oid FROM pg_class WHERE relname = $1",
&[42.into_datum()]
); That's not good. I've never been able to think of a way to safely handle this. I don't recall @workingjubilee and I talking about this problem in particular (just Spi soundness in general). Do you have any ideas, @YohDeadfall? |
That's for the evening.
You're nerd snipping me, don't you? But that's actually what I usually enjoy :D I have an idea in mind which requires storing the I will take a look closer when get back from my daily job. |
b53ec47
to
b19179b
Compare
we can't merge this without either releasing 0.13 after or using a generic that hopefully infers well? |
Generics will turn that into a non-breaking change, and as far as I know that trick is used somewhere in Bevy API, but maybe for a different reason. |
Ugh, that |
Yeah, I'm generally not a fan of |
b19179b
to
4eb4aa6
Compare
494225e
to
e4504cf
Compare
e4504cf
to
92f2817
Compare
Were you gonna try the generic/AsRef-using variant of this out so it doesn't require a breaking change? |
I tried it locally and noticed that it's a breaking change anyway due to a compilation error for What I can do then is accumulate breaking changes in some branch and ship them at once. It can be made on your side to avoid squashing commits there and reviewing changes one by one. Another option is to wait till I create enough pull requests and then merge them at once. |
Oh, I see. |
Superseded by #1858. |
Why to allocate query arguments on the heap only while they can also be placed on the stack? Why not both? (there should be that meme)
Another option is to introduce a little bit of generics and use
AsRef<T>
to accept anything, but deeply under the hood make non-generic methods using slices. Would it be better?I'm also thinking about that
Option<T>
used for the arguments. As for me, it's not different from having an empty slice or whatever from the implementation perspective, but from the usability point of view it's much clearer.Depends on #1837.