-
-
Notifications
You must be signed in to change notification settings - Fork 134
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
Syntax of specifying index with getAll() #6
Comments
Almost done... actually, working on making the Cursor enumerator work:
Right now, tracking down a "no such element" exception. |
Scratch that... Reread your commet 👍 |
Ah, sorry, didn't fully scroll horizontally and read your query. As with the Java driver, to specify optional arguments like
|
If you're using Visual Studio, soon as you hit You can also chain up multiple opt args:
|
That worked like a charm! |
👍 😃 |
The only downside with doing it like this, is that it don't follow the official API. Should the API try to parse the params if supplied as |
Ah, I see. That's true for the |
Okey, I see! That makes sense 😄 Since this works by calling the |
I do have an issue #1 to explore using allow anon types for opt args. I think it would also be pretty cool, and help syntactically, but AFAIK the only way to enumerate properties on Anonymous types is to use reflection (or possibly direct serialization from Newtonsoft). We'd have to investigate the performance bit more IMHO for serializing anonymous type opt args. Complexity probably wont be a big issue if we stick to using
|
The usual way in the other drivers is to use named/optional arguments if the language supports it. I think the |
I looked a bit more into getting optional arguments in the same line as the ReQL term call: Option A
In C#, the compiler forces us to always have Ultimately, this means any terms with JavaScript
Java
In the spirit of consistency and convention, if we decide to go this route (optArg first), we would probably require all terms with Thoughts? 💭 |
Also, asked the question in IRC. AtnNn suggested using a structure.... Option BIt appears we have enough metadata from
The ReQL for this would probably look like:
Some questionsCould we rely on I think the only benefit here is we'd get code-completion to help us navigate |
💭 also, thinking about this a bit more... and reviewing the overall architecture. It might be best to drop the whole Mainly, we'd have to do two conversions to support this anonymous
If we removed
Also, the API-ness of the Java
|
Disclaimer: I have not worked a lot with reflection, nor RethinkDB in general. |
As far as I know, there's no way during run-time to know specifically if an It's a bit ugly and not exactly proof. :/ |
I started a local branch with Option A; getting a feel for it's overall architecture. It does dramatically simplify the use of optional arguments and internal workings. |
I found a method for matching on Anonymous type on StackOverflow. It looks kind of similar to your method. Would it be possible to test the performance overhead? |
More on Option A: Just regenerated the AST using anonymous type Table Term
So, when We'd have this awkward situation where
|
LoL. Another Option C, abuse the language a bit and use operator indexer overloading...
Anders would probably scream, but does have an interesting ReQL syntax feel to it. ... and in a weird way, kinda makes sense. Feels right. Like you're injecting an anonymous Pros
Cons
💭 thoughts? |
It looks neat to me. There's sort of an interesting trade-off between "does this look like ReQL" and "does this look like C#". As far as optargs, my intention is to keep them up to date in the json data. It shouldn't be too hard since reql changes only happen in major versions, and we tag all of the issues with changes in them. While the java driver doesn't use the optarg info, I think it could provide a nice interface in other static languages |
I thought about it a lot over the weekend. I'm liking Option C indexer OptArg's. We can also support additional strongly typed OptArgs the same way with Option C if we ever decide to use fully typed optional arguments. My gut feeling about Option C is it might be worth deviating from the Java driver to get really cool syntax for ReQL's If anyone has any objections, please let me know. |
I decided to implement Option C while keeping Option A. I got the point of converting all the ReQL unit tests, and going solo with Option C was just too complex converting So, in all, the C# driver supports both: https://github.com/bchavez/RethinkDb.Driver#optional-arguments-with-getall |
While waiting for the cursor troubles to get implemented, I used a workaround to get results with getAll at all:
This returns three objects in a list. If I want to query a secondary index I have tried to change the
var result
to the following with no results:And if I try to change it to the following:
I get an error:
How do I query this in the right way?
The text was updated successfully, but these errors were encountered: