Skip to content

Commit

Permalink
Adding filter_ to Table.row() factory.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhermes committed Sep 7, 2015
1 parent 64adc6f commit 40b04fd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 10 additions & 3 deletions gcloud_bigtable/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,23 @@ def column_family(self, column_family_id, gc_rule=None):
"""
return ColumnFamily(column_family_id, self, gc_rule=gc_rule)

def row(self, row_key):
def row(self, row_key, filter_=None):
"""Factory to create a row associated with this table.
:type row_key: bytes
:param row_key: The key for the row being created.
:rtype: :class:`.row.Row`
:type filter_: :class:`.RowFilter`,
:class:`.RowFilterChain`,
:class:`.RowFilterUnion`, or
:class:`.ConditionalRowFilter`
:param filter_: (Optional) Filter to be used for conditional mutations.
See :class:`.Row` for more details.
:rtype: :class:`.Row`
:returns: A row owned by this table.
"""
return Row(row_key, self)
return Row(row_key, self, filter_=filter_)

def __eq__(self, other):
if not isinstance(other, self.__class__):
Expand Down
4 changes: 3 additions & 1 deletion gcloud_bigtable/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ def test_row_factory(self):

table = self._makeOne(TABLE_ID, None)
row_key = b'row_key'
row = table.row(row_key)
filter_ = object()
row = table.row(row_key, filter_=filter_)
self.assertTrue(isinstance(row, Row))
self.assertEqual(row.row_key, row_key)
self.assertEqual(row._table, table)
self.assertEqual(row._filter, filter_)

def test___eq__(self):
table_id = 'table_id'
Expand Down

0 comments on commit 40b04fd

Please sign in to comment.