-
Notifications
You must be signed in to change notification settings - Fork 26
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
Support named arguments #304
Conversation
I realised it probably doesn't need indexmap crate, it's possible to use simple |
fe37ae5
to
cb5ad3e
Compare
062d7a1
to
659964d
Compare
edgedb-protocol/src/query_arg.rs
Outdated
flag_link_property: false, | ||
flag_implicit: false | ||
}); | ||
fields.push(value.clone()); |
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.
I don't like .clone()
here, I think it's possible to avoid it, but I'm not sure how!
Also I'm not sure about |
I don't think so, no. |
Thanks for the contribution! I think this will suffer from the same problem that started all of this: it doesn't understand how to put the arguments in the correct order. It will need to consult the expected order from the server and put them in that order. |
Sure, but I think I would rather not merge #299 and instead do the logic
while handling named arguments themselves.
It seems weird to me to do the ordering at the object encoding layer, since
the object is ordered in the protocol.
…On Wed, Mar 27, 2024, 14:09 MrFoxPro ***@***.***> wrote:
Thanks for the contribution!
I think this will suffer from the same problem that started all of this:
it doesn't understand how to put the arguments in the correct order. It
will need to consult the expected order from the server and put them in
that order. It should also be able to get all of the cardinalities that way.
For me it works fine when merged with #299
<#299>
—
Reply to this email directly, view it on GitHub
<#304 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACTC7PUS5IQRUPVAMRYR4LY2MYRNAVCNFSM6AAAAABFK26ZLOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRTHE4TIOBWGE>
.
You are receiving this because your review was requested.Message ID:
***@***.***>
|
As I understand the problem is that now driver only checks edgedb-rust/edgedb-protocol/src/query_arg.rs Lines 195 to 246 in 0bf0949
|
Ok, maybe I exaggerated about level of effort required. |
@msullivan would it be sufficient to align input shape to required one here: edgedb-rust/edgedb-protocol/src/codec.rs Lines 657 to 691 in 0bf0949
I mean just walk over input shape elements, match corresponding element by name, place it in correct order and try to adjust correct cardinality? If so, is it worth to modify this PR and preserve only HashMap -> Value transformation? |
What I think that I would recommend (and this might be what you were saying), is to make an implementation of |
I was struggling with making something more generic than hashmap, ended up with simple solution. |
0e39a7c
to
82871e7
Compare
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.
The encoder looks good and matches what I had in mind.
Could you please add some tests for this? The rust bindings seem substantially under-tested, unfortunately, but we need to start improving that, and seeing examples as tests will make it easier to review the design of the interface.
I think the easiest way to add tests would be by adding them to edgedb-tokio/tests/func/client.rs
Also, I can read and write rust but I wouldn't call myself idiomatic; @aljazerzen could you please review the proposed interface here?
Actually running the tests requires the tests being able to find an
|
For sure, but I probably will wait for another review so I don't need to rewrite tests later too. |
Examples for providing eargs! {
"me" => 1 as i64,
"e" => None::<Vec<f32>>,
"q" => None::<String>,
"sphere" => None::<String>,
"lower" => None::<i64>,
"upper" => None::<i64>,
"geoarea" => None::<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.
This looks like a sound API design to me.
Before merging, take a look at the few low-priority comments I've left about naming and definitely add a few tests.
For an example, you can see the tests I've added in #308.
If you want, I can get this PR over the line.
I will be happy if you add tests |
671f98b
to
57b87f6
Compare
@MrFoxPro I've moved a few things around and added a bit of docs. Thank you for contributing! |
Basic usage: