-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add defaults to getattr, and defaults command on streams #27
Comments
@sojin this is because some of the documents don't have age as an attribute and rethink is strict about errors (if an attribute is missing and you try to use it, it'll throw an error). We'll make an api much nicer to deal with cases like this, but in the meantime you can try this:
|
Thanks, that did the trick.We are evaluating Rethink as an alternative for MongoDB, still trying to get my head around the docs. :) |
Great, all questions are welcome (irc, here, or google groups)! |
Ok, we need to add the following two enhacements: # Defaults in attr access
table('foo').filter(r['bar', 0] == 1).run()
# Defaults command on streams
table('foo').defaults({ 'bar': 0 }).filter(r['bar'] == 1).run() Moving to backlog, will address when some pressing initial issues are worked out. |
Can we have something to also have every attribute to default to nil? (I don't want to spend my time specifying the name of each attribute I'm going to use in the filter) |
I reopened #183, so we may try to find a different approach to this problem (although adding a modifier to evaluate missing attributes to nil is one option). |
I think a default command would be a good thing, though it shouldn't be used to address #183. I think there should be a ni | undefined value that behaves a lot like NaN and causes the row to be removed by default. |
The discussion if this has become a bit fractures but I think that were all
|
This may or may not be a dup of #183, depending on how we look at it. I'll consider this shortly. |
FYI -- |
This issue has now been subsumed by #570. Closing. |
Tried to add following document in addition to what is mentioned in
http://www.rethinkdb.com/docs/tutorials/superheroes/ (i.e after Inserting Multiple Documents as well)
.............
heroes.insert({
"hero": "Wolverine",
"name": "James 'Logan' Howlett",
"magazine_titles": ["Amazing Spider-Man vs. Wolverine", "Avengers", "X-MEN Unlimited", "Magneto War", "Prime"],
"age": "26",
"appearances_count": 98
}).run()
.............
i.e added extra field 'age'.
But apparently the filter on heroes.filter({'age': '26'}).run() throws below error:
rethinkdb.net.ExecutionError: Error while executing query on server: Object:
{
"appearances_count": 98,
"hero": "Wolverine",
"name": "James 'Logan' Howlett",
"magazine_titles": ["Amazing Spider-Man vs. Wolverine", "Avengers", "X-MEN Unlimited", "Magneto War", "Prime"],
"id": "fcd1ca53-9c78-4ce1-9b50-3e962cff2220"
}
is missing attribute "age"
db('python_tutorial').table('heroes').filter(((r['age'] == expr('26'))))
I'd expect, being Rethinkdb is schema-less, we could certainly add/remove any fields as required and filter later on.
The text was updated successfully, but these errors were encountered: