why does gql query result cause exception when calling get()

187 views Asked by At

I am attempting to retrieve an entry from my datastore with this:

 query = UserData.gql("WHERE mDeviceId = :1", id)
 Utils.log("my Object:" + str(query))
 entry = query.get()

It just so happens that the variable 'id' doesn't even exist (typo), so I know how to fix this, but I don't understand why the result I get won't let me call get() on it. When I do, I get the error:

Exception: Unsupported type for property  : <type 'builtin_function_or_method'>

Normally I just check if entry == None to see if I get no results. Does anyone know why this occurs and if I should be doing my checks for None differently, in case I have such typos in the future?

1

There are 1 answers

1
rmmh On BEST ANSWER

A variable named id is not defined in your code, so it passes the builtin function id, and QL complains that it's getting a function when it expected a value (integer?).

Check to make sure you're assigning id a value before you use it.

Even better, don't shadow builtins with your own variables-- it'll cause confusing errors like this. :-)