@@ -42,7 +42,7 @@ def test_ctor_defaults(self):
4242 self .assertEqual (query .filters , [])
4343 self .assertEqual (query .projection , [])
4444 self .assertEqual (query .order , [])
45- self .assertEqual (query .group_by , [])
45+ self .assertEqual (query .distinct_on , [])
4646
4747 def test_ctor_explicit (self ):
4848 from gcloud .datastore .key import Key
@@ -54,7 +54,7 @@ def test_ctor_explicit(self):
5454 FILTERS = [('foo' , '=' , 'Qux' ), ('bar' , '<' , 17 )]
5555 PROJECTION = ['foo' , 'bar' , 'baz' ]
5656 ORDER = ['foo' , 'bar' ]
57- GROUP_BY = ['foo' ]
57+ DISTINCT_ON = ['foo' ]
5858 query = self ._makeOne (
5959 client ,
6060 kind = _KIND ,
@@ -64,7 +64,7 @@ def test_ctor_explicit(self):
6464 filters = FILTERS ,
6565 projection = PROJECTION ,
6666 order = ORDER ,
67- group_by = GROUP_BY ,
67+ distinct_on = DISTINCT_ON ,
6868 )
6969 self .assertTrue (query ._client is client )
7070 self .assertEqual (query .project , _PROJECT )
@@ -74,7 +74,7 @@ def test_ctor_explicit(self):
7474 self .assertEqual (query .filters , FILTERS )
7575 self .assertEqual (query .projection , PROJECTION )
7676 self .assertEqual (query .order , ORDER )
77- self .assertEqual (query .group_by , GROUP_BY )
77+ self .assertEqual (query .distinct_on , DISTINCT_ON )
7878
7979 def test_ctor_bad_projection (self ):
8080 BAD_PROJECTION = object ()
@@ -86,10 +86,10 @@ def test_ctor_bad_order(self):
8686 self .assertRaises (TypeError , self ._makeOne , self ._makeClient (),
8787 order = BAD_ORDER )
8888
89- def test_ctor_bad_group_by (self ):
90- BAD_GROUP_BY = object ()
89+ def test_ctor_bad_distinct_on (self ):
90+ BAD_DISTINCT_ON = object ()
9191 self .assertRaises (TypeError , self ._makeOne , self ._makeClient (),
92- group_by = BAD_GROUP_BY )
92+ distinct_on = BAD_DISTINCT_ON )
9393
9494 def test_ctor_bad_filters (self ):
9595 FILTERS_CANT_UNPACK = [('one' , 'two' )]
@@ -284,29 +284,29 @@ def test_order_setter_multiple(self):
284284 query .order = ['foo' , '-bar' ]
285285 self .assertEqual (query .order , ['foo' , '-bar' ])
286286
287- def test_group_by_setter_empty (self ):
288- query = self ._makeOne (self ._makeClient (), group_by = ['foo' , 'bar' ])
289- query .group_by = []
290- self .assertEqual (query .group_by , [])
287+ def test_distinct_on_setter_empty (self ):
288+ query = self ._makeOne (self ._makeClient (), distinct_on = ['foo' , 'bar' ])
289+ query .distinct_on = []
290+ self .assertEqual (query .distinct_on , [])
291291
292- def test_group_by_setter_string (self ):
292+ def test_distinct_on_setter_string (self ):
293293 query = self ._makeOne (self ._makeClient ())
294- query .group_by = 'field1'
295- self .assertEqual (query .group_by , ['field1' ])
294+ query .distinct_on = 'field1'
295+ self .assertEqual (query .distinct_on , ['field1' ])
296296
297- def test_group_by_setter_non_empty (self ):
297+ def test_distinct_on_setter_non_empty (self ):
298298 query = self ._makeOne (self ._makeClient ())
299- query .group_by = ['field1' , 'field2' ]
300- self .assertEqual (query .group_by , ['field1' , 'field2' ])
299+ query .distinct_on = ['field1' , 'field2' ]
300+ self .assertEqual (query .distinct_on , ['field1' , 'field2' ])
301301
302- def test_group_by_multiple_calls (self ):
303- _GROUP_BY1 = ['field1' , 'field2' ]
304- _GROUP_BY2 = ['field3' ]
302+ def test_distinct_on_multiple_calls (self ):
303+ _DISTINCT_ON1 = ['field1' , 'field2' ]
304+ _DISTINCT_ON2 = ['field3' ]
305305 query = self ._makeOne (self ._makeClient ())
306- query .group_by = _GROUP_BY1
307- self .assertEqual (query .group_by , _GROUP_BY1 )
308- query .group_by = _GROUP_BY2
309- self .assertEqual (query .group_by , _GROUP_BY2 )
306+ query .distinct_on = _DISTINCT_ON1
307+ self .assertEqual (query .distinct_on , _DISTINCT_ON1 )
308+ query .distinct_on = _DISTINCT_ON2
309+ self .assertEqual (query .distinct_on , _DISTINCT_ON2 )
310310
311311 def test_fetch_defaults_w_client_attr (self ):
312312 connection = _Connection ()
@@ -427,7 +427,7 @@ def test_next_page_no_cursors_no_more_w_offset_and_limit(self):
427427 [{'kind' : self ._KIND , 'id' : self ._ID }])
428428 self .assertEqual (entities [0 ]['foo' ], u'Foo' )
429429 qpb = _pb_from_query (query )
430- qpb .limit = 13
430+ qpb .limit . value = 13
431431 qpb .offset = 29
432432 EXPECTED = {
433433 'project' : self ._PROJECT ,
@@ -557,14 +557,14 @@ def test_empty(self):
557557 self .assertEqual (list (pb .projection ), [])
558558 self .assertEqual (list (pb .kind ), [])
559559 self .assertEqual (list (pb .order ), [])
560- self .assertEqual (list (pb .group_by ), [])
560+ self .assertEqual (list (pb .distinct_on ), [])
561561 self .assertEqual (pb .filter .property_filter .property .name , '' )
562562 cfilter = pb .filter .composite_filter
563563 self .assertEqual (cfilter .operator , query_pb2 .CompositeFilter .AND )
564564 self .assertEqual (list (cfilter .filter ), [])
565565 self .assertEqual (pb .start_cursor , b'' )
566566 self .assertEqual (pb .end_cursor , b'' )
567- self .assertEqual (pb .limit , 0 )
567+ self .assertEqual (pb .limit . value , 0 )
568568 self .assertEqual (pb .offset , 0 )
569569
570570 def test_projection (self ):
@@ -636,9 +636,9 @@ def test_order(self):
636636 query_pb2 .PropertyOrder .DESCENDING ,
637637 query_pb2 .PropertyOrder .ASCENDING ])
638638
639- def test_group_by (self ):
640- pb = self ._callFUT (_Query (group_by = ['a' , 'b' , 'c' ]))
641- self .assertEqual ([item .name for item in pb .group_by ],
639+ def test_distinct_on (self ):
640+ pb = self ._callFUT (_Query (distinct_on = ['a' , 'b' , 'c' ]))
641+ self .assertEqual ([item .name for item in pb .distinct_on ],
642642 ['a' , 'b' , 'c' ])
643643
644644
@@ -653,7 +653,7 @@ def __init__(self,
653653 filters = (),
654654 projection = (),
655655 order = (),
656- group_by = ()):
656+ distinct_on = ()):
657657 self ._client = client
658658 self .kind = kind
659659 self .project = project
@@ -662,7 +662,7 @@ def __init__(self,
662662 self .filters = filters
663663 self .projection = projection
664664 self .order = order
665- self .group_by = group_by
665+ self .distinct_on = distinct_on
666666
667667
668668class _Connection (object ):
0 commit comments