Fixes issue 1017

https://github.com/rethinkdb/rethinkdb/issues/1017