Comments (2)
I think ReqlExpr is the right place to define them, that's basically what
the other drivers do
On Tue, Nov 3, 2015, 09:38 Brian Chavez [email protected] wrote:
In Josh's talk about the Java driver, there's a mention that Java doesn't
support operator overloading.
https://www.youtube.com/watch?v=emjzNpKoNkM#t=16m53sC# can support method overloading, seems like there's a lot we can do here
with C#'s method overloads.Some inspection on the Python driver:
class RqlQuery(object):
....
# The following are all operators and methods that operate on
# Rql queries to build up more complex operations# Comparison operators def __eq__(self, other): return Eq(self, other) def __ne__(self, other): return Ne(self, other) def __lt__(self, other): return Lt(self, other) def __le__(self, other): return Le(self, other) def __gt__(self, other): return Gt(self, other) def __ge__(self, other): return Ge(self, other) # Numeric operators ....
Looks like a whole new area we can improve on... we should be able to pull
off a lot of operator overloads for C#. This is pretty cool.In particular, with getField, the query in Josh's talk:
python: some_object["field"]["subfield"]
JavaScript: someObject("field")("subfield")
java: someObject.getField("field").getField("subfield")and in C# it may be possible do this type of query:
C#: r.db("mydb").table("users").get("id")["field"]["subfield"]
Looks legit.
My questions would be:
- What is the mapping between Python's class RqlQuery and Java's
AST? ReqlExpr or ReqlAst?
- In other words, I'm trying to understand where the correct mounting
point for the operator overloads would go in the AST ReqlExpr or
ReqlAst. My gut feeling here, operator overloads would go into ReqlExpr.
Terms like Db inherit from ReqlAst, and doesn't make sense for
operator overloads to live in ReqlAst super class because operator
overloads would be available on the Db term. ReqlExpr seems like the
best place.
- In particular with .getField, is there a strict subset of terms
that can have .getField() called on? With .optArg there was a
distinction between terms with and without .optArg() calls. I'm just
wondering if the same could be true with .getField() if Java
supported operator overloading.@deontologician https://github.com/deontologician
Thanks for your insight [image: 👍]
—
Reply to this email directly or view it on GitHub
#9.
from rethinkdb.driver.
Just finished operator overloading .. it's crazy insane:
new Foo {id = "a", Baz = 1, Bar = 1}
new Foo {id = "b", Baz = 2, Bar = 2}
new Foo {id = "c", Baz = 3, Bar = 3}
var expA = r.db(DbName).table(TableName).get("a")["Baz"];
var expB = r.db(DbName).table(TableName).get("b")["Bar"];
int add = (expA + expB).run<int>(conn);
add.Should().Be(3);
AND IT WORKS! 💥 Thanks again Josh for all the help! :)
from rethinkdb.driver.
Related Issues (20)
- Create a method to return result as raw json HOT 4
- Resolution function on OptArg insert conflict HOT 1
- ConnectionPool.Builder.ConnectAsync does not respect InitialTimeout() HOT 4
- Add Error codes to Exceptions HOT 2
- Additional exceptions thrown when trying to cancel Cursor.MoveNextAsync() HOT 6
- Object's primary key and key of RunAtom() is different (Client-side generation). HOT 4
- Support for System.Text.Json.JsonDocument
- Cursor<T> should implement IAsyncEnumerable<T> in .net core 3
- RethinkDB 2.4 Release
- Best options: RunResult, RunAtom or RunCursor HOT 3
- Get list from Table that contains 'A' in the 'message' field HOT 1
- ASL 2.0 HOT 1
- Implement lambda functions as a possible argument in Insert().OptArgs("conflict",...) HOT 1
- System.NullReferenceException HOT 1
- Add EntityFramework support to Linq provider HOT 5
- Polymorphism HOT 1
- Various exceptions when updating a document HOT 1
- System.Configuration.ConfigurationErrorsException: HOT 1
- Wrong OptArg serialisation after OrderBy
- Insert not working with RunNoReply & Can't use runOpts is always null -- solved
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rethinkdb.driver.