rom-rb / rom

Data mapping and persistence toolkit for Ruby
https://rom-rb.org
MIT License
2.09k stars 161 forks source link

Use dry-types/dry-struct from master #478

Closed flash-gordon closed 6 years ago

flash-gordon commented 6 years ago

@solnic I wonder what's our plan for default types. It's easy to make them work as before (i.e. nil triggers a default value) but I think we should change this behavior in the next version. FYI SQL's defaults work in the same way, if you insert NULL it doesn't use the default value.

solnic commented 6 years ago

To be honest, this should be adapter-specific. ie if a database supports default values, then it should be used. Using default values in structs that rom loads is a code smell for me.

flash-gordon commented 6 years ago

@solnic it's more about input schemas that inject a default value on nil. I would argue they should do it on missing key instead.

solnic commented 6 years ago

@flash-gordon ah right, well, would be good to maintain treating nil as a trigger for default value. Otherwise we'd have to rewrite input hashes every time a command is applied, which may have negative performance impact.

flash-gordon commented 6 years ago

@solnic hm, actually, I can't see what's the difference between these approaches, even nils have to be overridden with default values, hashes will be rewritten in both cases