vapor / fluent-kit

Swift ORM (queries, models, and relations) for NoSQL and SQL databases
MIT License
211 stars 116 forks source link

Fluent Models malfunction if given a property named `description` #588

Open gwynne opened 10 months ago

gwynne commented 10 months ago

Due to the CustomStringConvertible conformance provided by AnyModel, the rules of dynamic dispatch through existentials, and the behavior of Mirror, Fluent malfunctions badly if a model tries to provide an optional description property as a database field. There is no warning from the compiler or the framework for this scenario and no indication whatsoever of the underlying cause. Fluent needs to either trigger an assertion as easily as possible for such properties, or - much more preferably - handle them gracefully. (Note: The latter is badly complicated by the fact that it would be a semver-major break to remove the CustomStringConvertible conformance from AnyModel. Look into whether sneaking around the problem using something like the @_implements attribute would work.)