Showing posts with label Google AppEngine. Show all posts
Showing posts with label Google AppEngine. Show all posts

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.

Thursday, May 13, 2010

Gql and object inheritance

I am working on an AppEngine project using the Kay Framework.
I was testing my queries in Kay Framework's shell. If you are familiar with Django's shell it is essentially the same.

Running the following query :
query = db.GqlQuery("select * from MyUserObject where user_name = :1 and password = :2")
I got this error :
raise KindError('No implementation for kind \'%s\'' % kind)
I had imported the object. My object inherits from the framework's DatatstoreUser.


Changing to the following :
query = MyUserObject.gql("where user_name = :1", "testuser@testuser.com")
provided exactly what I needed.