Comments (5)
I'd say without should error here.
My feeling is that we should error by default and offer people a way to have it not error if it's not found. Maybe we'd also want a way to have a default value for the plucks. I prefer this because compensating for missing parameters winds up being a big pain since it comes up in so many places and I don't think it's good to make people learn different rules for each case. Better to just consistently error if a parameter is missing and give people ways to have default values.
from rethinkdb.
Hi - I am woogley from IRC. To quickly illustrate my point:
r.db('test').tableCreate('shows').run()
r.db('test').table('shows').insert([ { name: 'Star Trek' }, { name: 'Breaking Bad', rating: 5 } ]).run()
Now, a vanilla run() will return:
[{"name":"Star Trek","id":"960e0533-4aa7-4c27-ae63-557f7dee92ca"},{"name":"Breaking Bad","rating":5,"id":"9d9690d5-e7bc-42e6-bab6-2e73c6c90422"}]
(The Star Trek entry simply lacks the rating
key)
However, if you pluck:
r.db('test').table('shows').pluck('name', 'rating').run()
It throws this error:
Runtime Error: Attempting to pick missing attribute rating from data:
So I would say the inconsistency has less to do with without()
and more to do with a vanilla run()
on the table.
I would expect the pluck()
to behave the same as a normal run()
and let my application code deal with the missing key.
from rethinkdb.
I think the behavior is correct as is. The server always behaves consistently -- if the query tries to evaluate an attribute and the attribute doesn't exist, it throws an error. If the query doesn't need to evaluate the attribute, the server proceeds as planned. In case of without
, the value of the attribute isn't evaluated, so the error isn't thrown. Similarly, in case of run, the server evaluates the row, not the attribute, so everything works as expected as well.
As far as making dealing with these errors easier on the user, I agree with @jdoliner -- we'll address it via #27.
from rethinkdb.
So the way to do this right now is as follows:
r.db('test').table('shows').map(lambda x: r.merge({"rating" : null}, x).pluck('name', 'rating').run()
Not pretty but it will let you run the query and have nulls filled in for the other values. Having defaults is in essence sugar for this command.
from rethinkdb.
Added an issue to make it more pleasant, see #45.
from rethinkdb.
Related Issues (20)
- Error in thread 2 in src/arch/runtime/context_switching.cc at line 362 HOT 1
- Rethinkdb Proxy
- Set a name to a proxy name HOT 3
- Add "Buffers" from /proc/meminfo in parse_meminfo_file to determine available memory
- download.rethinkdb.com is down, 502 Bad Gateway HOT 1
- Evaluate Profile-Guided Optimization (PGO) on RethinkDB
- error: to_string called on an uninitialized ip_address_t, addr_type: 0 compiling rethinkdb on Raspberry HOT 6
- RethinkDB not fully supported on Raspberry PI OS Bullseye (32/64 bit) HOT 10
- Reasonable to change hard-coded cluster size? HOT 5
- help bro my issue = warn: Problem when checking for new versions of RethinkDB: HTTP request to update.rethinkdb.com failed. HOT 1
- cluster connect/reconnect timeout HOT 1
- Installation fails in Kubuntu 23.10 HOT 4
- Generate web_assets.cc in a repeatable file order HOT 1
- Avoid full paths of coffeescript files in generation of web_assets.cc HOT 2
- Rethinkdb 2.4.4 release list HOT 11
- Support protobuf 25
- Return multiple changes feed
- Cache miss rate measurements HOT 4
- Something i forgot to had when having the default doc like so
- Connect rethinkdb directly from browser ? HOT 1
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.