Search code examples
rethinkdbrethinkdb-javascript

rethinkdb 'or' filter still returning result even filter params is invalid


I'm trying to retrieve a result where row 'origin' is equal to 'person' or row 'type' is equal to 'human', below is what I've tried

r.db('identitydb').table('connections').filter( 
  ( { "origin" : "person" } ) | ( { "type" : "human" } )
);

yes it did return but the problem is even if I put an invalid values e.g.

r.db('identitydb').table('connections').filter( 
  ( { "origin" : "persss" } ) | ( { "type" : "humaxxxn" } )
);

it still returns the result above like it simply not filtering. Below is the return result

{ "created_at": "January 06, 2019 | 07:32 AM" , "id": "99f84427-422b-4768-bed8-4d08fc62ff15" , "origin": "human" , "type": "person" }

I even tried

r.db('identitydb').table('connections').filter( 
  ( r.row["origin"] == "person" ) | ( r.row["type"] == "human" )
);

but unfortunately, same result. Any help, ideas please?


Solution

  • I am confused that you tagged your question with "rethinkdb-javascript" but your queries are for the python driver. The javascript version of your query works fine:

    r.db("identitydb").table("connections")
       .filter(r.row("origin").eq("person").or(r.row("type").eq("human")))