Do not map NULL values to Mongo but simply drop them, as MongoDB is schemaless.
authorAli Asad Lotia <ali@anobii.com>
Mon, 30 Apr 2012 14:12:02 +0000 (10:12 -0400)
committerGreg Sabino Mullane <greg@endpoint.com>
Mon, 30 Apr 2012 14:12:02 +0000 (10:12 -0400)
Bucardo.pm

index 02f39efaf5dd21c9e5864babe9dcbe3158b0e9b7..32225184dd85321deb2989a864f203c7ea194ad1 100644 (file)
@@ -8526,7 +8526,11 @@ sub push_rows {
                         }
                         ## Coerce non-strings into different objects
                         for my $key (keys %$object) {
-                            if ($goat->{columnhash}{$key}{ftype} =~ /smallint|integer|bigint/o) {
+                            ## Since mongo is schemaless, don't set null columns in the mongo doc
+                            if (!defined($object->{$key})) {
+                                delete $object->{$key};
+                            }
+                            elsif ($goat->{columnhash}{$key}{ftype} =~ /smallint|integer|bigint/o) {
                                 $object->{$key} = int $object->{$key};
                             }
                             elsif ($goat->{columnhash}{$key}{ftype} eq 'boolean') {