luckyframework/lucky_record

Model definition can't have a `value` column

sdzyba opened this issue · 1 comments

Crystal version: 0.25.1
LuckyRecord version: 0.6.0

When having a model with defined value column in it like so:

table :items do
  column value : String
end

user would get an error:

...
228.       def set_value_from_param(value)
 229.         parse_result = String::Lucky.parse(value)
 230.         if parse_result.is_a? LuckyRecord::Type::SuccessfulCast
>231.           value.value = parse_result.value
 232.         else
 233.           value.add_error "is invalid"
 234.         end
 235.       end
 236.
...

undefined method 'value=' for String
Rerun with --error-trace to show a complete error trace.

Not sure if it's just a bug or value is a reserved name for column. If it's reserved indeed like a type column name may be reserved for STI then having some kind of informative warning may be helpful.

That is a legit bug. value is not a reserved keyword. PR with a fix is in review. Thanks for reporting!