Having a model called Type is not well supported
I did
amber g scaffold Type label:string
other scaffolding, then
amber watch
Actual behavior: https://pastebin.com/P9En4Qsn
→ amber --version
Amber CLI (amberframework.org) - v0.11.1
→ crystal --version
Crystal 0.27.0 (2018-11-04)
LLVM: 6.0.1
Default target: x86_64-apple-macosx
Yeah, there are several reserved words in Crystal and Amber. Not sure the best way to deal with this except maybe check to see if someone is trying to use one and prevent it.
I think the keyword Type might be reserved
Not sure if this is an issue we should worry about. There are multiple key words in most other frameworks including Rails, Phoenix that you just need to know not to use.
From a usability perspective, it's probably best to have a blacklist of names that error the generators and prevent them from dropping a bunch of broken code into a project.
Several times with Rails I've attempted to generate a model/controller/etc and the generation succeeds but then the resultant code wouldn't work because of reserved words.
@robacarp Is there a list of reserved words we should check for?
Well, I'm not sure what all would be in an exhaustive list but it could start with Type, Array, Int32, etc. Plan for eventual completeness?
The list from that issue at least looks like a good start. Do we want to check for these words in https://github.com/amberframework/amber/blob/master/src/amber/cli/generators/scaffold.cr or at a higher level in the commands chain? Should we return an exception or a pretty console output? Working on a PR to close out this issue.
Most helpful comment
From a usability perspective, it's probably best to have a blacklist of names that error the generators and prevent them from dropping a bunch of broken code into a project.
Several times with Rails I've attempted to generate a model/controller/etc and the generation succeeds but then the resultant code wouldn't work because of reserved words.