Permalink
Browse files

Return timestamp from insert() methods

Fixes #113
  • Loading branch information...
1 parent 2b5dafa commit 27418b9400a5b42ef30d5689c7fd9579a832cbab @thobbs thobbs committed Jan 20, 2012
Showing with 8 additions and 4 deletions.
  1. +4 −2 pycassa/columnfamily.py
  2. +2 −1 tests/test_columnfamily.py
  3. +2 −1 tests/test_columnfamilymap.py
View
@@ -861,14 +861,16 @@ def insert(self, key, columns, timestamp=None, ttl=None,
colname = self._pack_name(colname, False)
column = Column(colname, colval, timestamp, ttl)
- return self.pool.execute('insert', packed_key, cp, column,
+ self.pool.execute('insert', packed_key, cp, column,
write_consistency_level or self.write_consistency_level)
else:
mut_list = self._make_mutation_list(columns, timestamp, ttl)
mutations = {packed_key: {self.column_family: mut_list}}
- return self.pool.execute('batch_mutate', mutations,
+ self.pool.execute('batch_mutate', mutations,
write_consistency_level or self.write_consistency_level)
+ return timestamp
+
def batch_insert(self, rows, timestamp=None, ttl=None, write_consistency_level = None):
"""
Like :meth:`insert()`, but multiple rows may be inserted at once.
@@ -51,7 +51,8 @@ def test_insert_get(self):
key = 'TestColumnFamily.test_insert_get'
columns = {'1': 'val1', '2': 'val2'}
assert_raises(NotFoundException, cf.get, key)
- cf.insert(key, columns)
+ ts = cf.insert(key, columns)
+ assert_true(isinstance(ts, int))
assert_equal(cf.get(key), columns)
def test_insert_multiget(self):
@@ -83,7 +83,8 @@ def test_empty(self):
def test_insert_get(self):
instance = self.instance('TestColumnFamilyMap.test_insert_get')
assert_raises(NotFoundException, self.map.get, instance.key)
- self.map.insert(instance)
+ ts = self.map.insert(instance)
+ assert_true(isinstance(ts, int))
assert_equal(self.map.get(instance.key), instance)
def test_insert_get_omitting_columns(self):

0 comments on commit 27418b9

Please sign in to comment.