İnvalid Where Clause

Hi Backendless Team,
I have a problem. Why this code get error ? ( invalid Where Clause ) user_id that in house table column is related with users table.
let user = backendless.userService.currentUser
let query = BackendlessDataQuery()
query.whereClause = “user_id = (user)”
backendless.persistenceService.of(House.ofClass()).find(
query,
response: { ( houses : BackendlessCollection!) -> () in
let currentPage = houses.getCurrentPage()

for selector in currentPage as! [House] {

Hi Alican,

The problem is in this line:

query.whereClause = "user_id = \(user)"

It should be written like this (string values must be surrounded by single quotes):

query.whereClause = "user_id = '\(user)'"

Regards,
Mark

Hi Mark,I tried your suggestion but it doesn’t work.

ERROR: Server reported an error: FAULT = ‘1017’ [Invalid where clause: Unknown column 'where clause] <Invalid where clause: Unknown column 'where clause>

user_id column is in House table.user_id related with user table,Why do I take this error ?

http://support.backendless.com/public/attachments/3f62805cfb66330add0a7628e7804436.png&lt;/img&gt;

How should WhereClause be for relationship column ?

Since user_id is a relation column, you must reference a PROPERTY of the related object:

user_id.objectId = ‘value’

Thank you Mark.

I’m having the same issue in Java.

BackendlessDataQuery rQuery = new BackendlessDataQuery();
String whereClause = “recipeName =” + recipe_name;
rQuery.setWhereClause(whereClause);

You need to surround the recipe_name with single quotes or backticks.

String whereClause = "recipeName='" + recipe_name + "'";

or

String whereClause = "recipeName=`" + recipe_name + "`";

I am also having same problem…
BackendlessUser currentUser = Backendless.UserService.CurrentUser();
BackendlessDataQuery dataQuery = new BackendlessDataQuery();
dataQuery.setWhereClause( “email.ObjectId=”+currentUser.getObjectId());

Its a relation column but still i am getting error as Server reported an error - Invalid where clause
Kindly help