Permalink
Browse files

Fix to properly handle null values in inserts and saves (when object …

…already exists with non-null values).
  • Loading branch information...
1 parent 72d7306 commit 447134af8e6f425e1c6eba7a0c7ac12c49698cb9 @bflorian committed Nov 19, 2012
View
24 ...groovy/com/reachlocal/grails/plugins/cassandra/astyanax/AstyanaxPersistenceMethods.groovy
@@ -195,20 +195,38 @@ class AstyanaxPersistenceMethods
void putColumns(mutationBatch, columnFamily, rowKey, columnMap)
{
- mutationBatch.withRow(columnFamily, rowKey).putColumns(columnMap)
+ def r = mutationBatch.withRow(columnFamily, rowKey)
+ columnMap.each {k, v ->
+ if (v != null) {
+ r.putColumn(k, v, null)
+ }
+ else {
+ r.deleteColumn(k)
+ }
+ }
}
void putColumns(mutationBatch, columnFamily, rowKey, columnMap, ttlMap)
{
def r = mutationBatch.withRow(columnFamily, rowKey)
if (ttlMap instanceof Number) {
columnMap.each {k, v ->
- r.putColumn(k, v, ttlMap)
+ if (v != null) {
+ r.putColumn(k, v, ttlMap)
+ }
+ else {
+ r.deleteColumn(k)
+ }
}
}
else {
columnMap.each {k, v ->
- r.putColumn(k, v, ttlMap[k])
+ if (v != null) {
+ r.putColumn(k, v, ttlMap[k])
+ }
+ else {
+ r.deleteColumn(k)
+ }
}
}
}

0 comments on commit 447134a

Please sign in to comment.