Jean-Tiare Le Bigot  committed a9e23eb

Fixed potential data loss.

* field 'levelname' has 'first' as default value
* when game is completed, it is reset to '' and saved
* as empty strings are *not* stored in DynamoDB, the field is removed from DDB
* when the object is reloaded from DDB, the field is detected as missing
* a default value is loaded: 'first'

this commit loads default values from schema in constructors. When loading from DDB,
all fields are reset to empty defaults

  • Participants
  • Parent commits 5011b82
  • Branches default

Comments (0)

Files changed (1)

File dynamodb_mapper/

         for (name, type_) in cls.__schema__.iteritems():
             # Set the value if we got one from DynamoDB. Otherwise, stick with the default
             value = _dynamodb_to_python(type_, d.get(name))
-            if value is not None:
-                setattr(instance, name, value)
+            if value is None:
+                value = _get_default_value(type_)
+            setattr(instance, name, value)
         return instance