onyxframework / sql

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

Ability to mark fields as non-nilable #25

Closed vladfaust closed 6 years ago

vladfaust commented 6 years ago

In real world models can have fields which are NOT NULL; but in Core developer still has to write model.field.not_nil! when working with such a field.

Proposal:

class User < Core::Model
  schema do
    field :username, String
    field :age, Int32?
  end
end

Should expand to:

class User < Core::Model
  getter! username, String?
  getter age : Int32?
end