Skip to content

Commit

Permalink
OGM-618 Don't store null in association rows for map-based stores
Browse files Browse the repository at this point in the history
  • Loading branch information
gunnarmorling authored and emmanuelbernard committed Dec 4, 2014
1 parent 8d38803 commit f3a5c0d
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,20 @@ private MapHelpers() {
}

public static void applyTupleOpsOnMap(Tuple tuple, Map<String, Object> map) {
applyTupleOpsOnMap( tuple, map, true );
}

public static void applyTupleOpsOnMap(Tuple tuple, Map<String, Object> map, boolean putNulls) {
for ( TupleOperation action : tuple.getOperations() ) {
switch ( action.getType() ) {
case PUT_NULL:
if ( putNulls ) {
map.put( action.getColumn(), action.getValue() );
}
else {
map.remove( action.getColumn() );
}
break;
case PUT:
map.put( action.getColumn(), action.getValue() );
break;
Expand All @@ -55,7 +66,7 @@ public static Map<String, Object> tupleToMap(Tuple tuple) {
snapshot = ( (MapTupleSnapshot) snapshotInstance ).getMap();
}
Map<String, Object> map = new HashMap<String, Object>( snapshot );
MapHelpers.applyTupleOpsOnMap( tuple, map );
MapHelpers.applyTupleOpsOnMap( tuple, map, false );
return map;
}

Expand Down

0 comments on commit f3a5c0d

Please sign in to comment.