App Engine 1.6.5 Released

265 views
Skip to first unread message

Marzia Niccolai

unread,
Apr 24, 2012, 5:34:56 PM4/24/12
to Google App Engine
Hi,

We've released 1.6.5 today, with some really cool features you can read about here: http://googleappengine.blogspot.com/2012/04/app-engine-165-released.html

One of the most exciting is projection queries, the description of which I'll crib from the above post:

"We’ve introduced an experimental type of query, projection queries, in the Datastore. For the SQL fans amongst us, this is similar to queries of the form:

SELECT Property1, Property2 FROM MyEntity ORDER BY Property3

Projection queries have the same cost and performance characteristics as keys-only queries but return entity objects populated only with the requested properties."

Python docs:

Java docs:

Sun Jing

unread,
Apr 24, 2012, 11:58:38 PM4/24/12
to google-a...@googlegroups.com
I tried to use projection queries:

class Article(db.Model):
title = db.StringProperty(required=True)
# others...

print db.Query('Article', projection=('title')).get()
Traceback (most recent call last):
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/admin/__init__.py", line 331, in post
    exec(compiled_code, globals())
  File "<string>", line 3, in <module>
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/db/__init__.py", line 2098, in get
    results = self.run(limit=1, **kwargs)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/db/__init__.py", line 2061, in run
    raw_query = self._get_query()
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/db/__init__.py", line 2446, in _get_query
    kind = self._model_class.kind()
AttributeError: 'str' object has no attribute 'kind'

print db.GqlQuery("SELECT title FROM Article").get().title
# this one works

Alfred Fuller

unread,
Apr 25, 2012, 12:09:34 AM4/25/12
to google-a...@googlegroups.com
('title') is not a tuple, you need to use ('title',) or ['title'] instead

>>> print ('title')
title
>>> print ('title',)
('title',)
>>> 

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To post to this group, send email to google-a...@googlegroups.com.
To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.

Alfred Fuller

unread,
Apr 25, 2012, 12:53:20 AM4/25/12
to google-a...@googlegroups.com
Oh, also db.Query takes a class not a string, should be:
db.Query(Article, projection=('title',)).get() 

Sun Jing

unread,
Apr 25, 2012, 12:58:38 AM4/25/12
to google-a...@googlegroups.com
Thank you, Alfred.
Can I change projection if I use Model.all() to create a Query object?

Alfred Fuller

unread,
Apr 25, 2012, 1:03:00 AM4/25/12
to google-a...@googlegroups.com
You can pass the projection in as a keyword argument to any of the query functions:

Article.all().run/fetch/get(projection=('title',))

Sun Jing

unread,
Apr 25, 2012, 1:41:03 AM4/25/12
to google-a...@googlegroups.com
Thank you, it works. I think the document should be updated:

Alfred Fuller

unread,
Apr 25, 2012, 2:13:30 AM4/25/12
to google-a...@googlegroups.com
I agree :-), the doc update is in progress.

On Tue, Apr 24, 2012 at 10:41 PM, Sun Jing <kea...@gmail.com> wrote:
Thank you, it works. I think the document should be updated:

--

Gopal Patel

unread,
Apr 25, 2012, 4:23:03 AM4/25/12
to google-a...@googlegroups.com
does ndb supports projection query ?

Ian Marshall

unread,
Apr 25, 2012, 6:44:24 AM4/25/12
to Google App Engine
As a Java person, am I correct to restrain my enthusiasm and wait for
the 1.6.5.1 Java release?


On Apr 24, 10:34 pm, Marzia Niccolai <marce+appeng...@google.com>
wrote:
> Hi,
>
> We've released 1.6.5 today, with some really cool features you can read
> about here:http://googleappengine.blogspot.com/2012/04/app-engine-165-released.html
>
> One of the most exciting is projection queries, the description of which
> I'll crib from the above post:
>
> "We’ve introduced an experimental type of query, projection queries, in the
> Datastore. For the SQL fans amongst us, this is similar to queries of the
> form:
>
> SELECT Property1, Property2 FROM MyEntity ORDER BY Property3
>
> Projection queries have the same cost and performance characteristics as
> keys-only queries but return entity objects populated only with the
> requested properties."
>
> Python docs:https://developers.google.com/appengine/docs/python/datastore/queries...
>
> Java docs:https://developers.google.com/appengine/docs/java/datastore/queries#Q...
>
> Enjoy!
> -Marzia

Maxim Lacrima

unread,
Apr 25, 2012, 8:16:58 AM4/25/12
to google-a...@googlegroups.com
Does this release include a fix for this issue:

I still have problems described there if I do large asynchronous puts.

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To post to this group, send email to google-a...@googlegroups.com.
To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.



--
with regards,
Maxim

pdknsk

unread,
Apr 25, 2012, 1:39:12 PM4/25/12
to Google App Engine
When using projection queries for just a single property, does this
also return keys? The answer is probably yes, as returned items can
probably not be key-less, or can they?

Alfred Fuller

unread,
Apr 25, 2012, 2:08:49 PM4/25/12
to google-a...@googlegroups.com
Projection queries return the properties you projected and key for each entity that matches the query.

Ron Wilhelm

unread,
Apr 25, 2012, 3:47:55 PM4/25/12
to Google App Engine
GQL on ndb models supports projection queries.

-Ron

On Apr 25, 2:23 am, Gopal Patel <patelgo...@gmail.com> wrote:
> does ndb supports projection query ?
>
>
>
>
>
>
>
> On Wed, Apr 25, 2012 at 11:43 AM, Alfred Fuller <arful...@google.com> wrote:
> > I agree :-), the doc update is in progress.
>
> > On Tue, Apr 24, 2012 at 10:41 PM, Sun Jing <kea...@gmail.com> wrote:
>
> >> Thank you, it works. I think the document should be updated:
>
> >>https://developers.google.com/appengine/docs/python/datastore/querycl...

Alfred Fuller

unread,
Apr 25, 2012, 8:44:12 PM4/25/12
to google-a...@googlegroups.com

ndb does not yet officially support projection queries, so there might be some rough edges if you use them.

Warwick Allison

unread,
Apr 25, 2012, 9:26:40 PM4/25/12
to Google App Engine
Projection queries do not seem to work for properties that are
db.ReferenceProperty(). So for example, this works:

SELECT * FROM Person

result.mother.name + " is the mother of " + result.name

but this does not:

SELECT name,mother,father FROM Person

Is this just an oversight, or an undocumented permanent limitation?
(if the former, I'll wait, if the latter I may redesign my db to not
use ReferenceProperty just to see what the performance improvement is
like!).

(no, I don't actually have a Person database, this is an example ;-)

Emanuele Ziglioli

unread,
Apr 30, 2012, 12:01:35 AM4/30/12
to Google App Engine
Reply all
Reply to author
Forward
0 new messages