onyxframework / sql

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

Only select annotated on initialize #105

Closed Blacksmoke16 closed 2 years ago

Blacksmoke16 commented 5 years ago

https://github.com/onyxframework/sql/blob/84734a8803a475e94def3ed590896d1959fdc6b8/src/onyx-sql/serializable.cr#L195

Trying to include my CrSerializer shard and I'm hitting Character@validator must be nilable, as it's an Onyx::SQL::Serializable variable.

Probably could just select the ivars that have an annotation vs just assuming all of them are Serializable variables.

vladfaust commented 5 years ago

Welcome, @Blacksmoke16! 😀

I think that it would be better to skip explicitly ignored variables, just like in other serializables.

Blacksmoke16 commented 5 years ago

That would be a bit tricky for ivars that are included via other shards. Would either have to reopen the definition of the ivar to add a shard specific annotation, or include it in the source. It wouldn't be as bad if there was a standard "ignore this" annotation but alas that isn't the case.