Sunday, May 16, 2010

Parse Error: Expected no additional symbols at symbol select

Running the following query :
query = MODEL_NAME.gql("select * from MODEL_NAME where name = :1", supplied_name) 
I got the error below :
Traceback (most recent call last):                                                               
File "<console>", line 1, in <module>
File "[PATH TO APP ENGINE INSTALL]google_appengine_1.3.1/google/appengine/ext/db/__init__.py", line 1100, in gql
*args, **kwds)
File "[PATH TO APP ENGINE INSTALL]google_appengine_1.3.1/google/appengine/ext/db/__init__.py", line 2047, in __init__
self._proto_query = gql.GQL(query_string, _app=app)
File "[PATH TO APP ENGINE INSTALL]google_appengine_1.3.1/google/appengine/ext/gql/__init__.py", line 192, in __init__
if not self.__Select():
File "[PATH TO APP ENGINE INSTALL]google_appengine_1.3.1/google/appengine/ext/gql/__init__.py", line 799, in __Select
return self.__From()
File "[PATH TO APP ENGINE INSTALL]google_appengine_1.3.1/google/appengine/ext/gql/__init__.py", line 820, in __From
return self.__Where()
File "[PATH TO APP ENGINE INSTALL]google_appengine_1.3.1/google/appengine/ext/gql/__init__.py", line 833, in __Where
return self.__OrderBy()
File "[PATH TO APP ENGINE INSTALL]google_appengine_1.3.1/google/appengine/ext/gql/__init__.py", line 1056, in __OrderBy
return self.__Limit()
File "[PATH TO APP ENGINE INSTALL]google_appengine_1.3.1/google/appengine/ext/gql/__init__.py", line 1098, in __Limit
return self.__Offset()
File "[PATH TO APP ENGINE INSTALL]google_appengine_1.3.1/google/appengine/ext/gql/__init__.py", line 1117, in __Offset
return self.__Hint()
File "[PATH TO APP ENGINE INSTALL]google_appengine_1.3.1/google/appengine/ext/gql/__init__.py", line 1140, in __Hint
return self.__AcceptTerminal()
File "[PATH TO APP ENGINE INSTALL]google_appengine_1.3.1/google/appengine/ext/gql/__init__.py", line 784, in __AcceptTerminal
self.__Error('Expected no additional symbols')
File "[PATH TO APP ENGINE INSTALL]google_appengine_1.3.1/google/appeng
ine/ext/gql/__init__.py", line 724, in __Error
(error_message, self.__symbols[self.__next_symbol]))
BadQueryError: Parse Error: Expected no additional symbols at symbol select
This is a simple fix:
query = MODEL_NAME.gql("select * from MODEL_NAME where name = :1", supplied_name) 
App Engine's orm is already supplying the "select * from" part of the query.

2 comments:

Daniel said...

Remove "SELECT * FROM"

gql() have implicit "SELECT * FROM"

Edu Reis said...

I had the same issue, i tried what Daniel Said and it works to me.

Thanks Daniel.