onyxframework / sql

A delightful SQL ORM ☺️
https://api.onyxframework.com/sql
MIT License
91 stars 7 forks source link

Support of the Bool type #35

Closed egillet closed 6 years ago

egillet commented 6 years ago

The bool type is not working now. The offending line is in model/schema/mapping.cr at line 80:

@\\{{field[:name].id}} = value.as(\\{{field[:type].id}}) || \\{{field[:default] || nil.id}} 

The || operator is not working for false value, and it replaces false by nil (or the default value). A possible solution is to replace the line by this:

@\\{{field[:name].id}} = value.nil? ? \\{{field[:default] || nil.id}} : value.as(\\{{field[:type].id}})