Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

…already exists with non-null values).
  • Loading branch information...
commit 447134af8e6f425e1c6eba7a0c7ac12c49698cb9 1 parent 72d7306
@bflorian authored
View
24 ...groovy/com/reachlocal/grails/plugins/cassandra/astyanax/AstyanaxPersistenceMethods.groovy
@@ -195,7 +195,15 @@ 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)
@@ -203,12 +211,22 @@ class AstyanaxPersistenceMethods
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)
+ }
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.