Closed hyouuu closed 2 years ago
The codebase uses lots of model.id! e.g. https://github.com/vapor/fluent-kit/blob/main/Sources/FluentKit/Model/Model%2BCRUD.swift#L74, and if a model was newly created using a custom init without generating the id yet (e.g. on iOS client), accessing model.id! causes instant crash. Instead, we should guard and throw an exception.
model.id!
init
id
guard
model.delete()
An exception should be thrown as delete etc are throwing functions
delete
I'm using fluent-sqlite-driver of main branch via SPM in Xcode on iOS 15.4, which depends on FluentKit
fluent-sqlite-driver
main
FluentKit
How can I assign this issue to myself?
@ahmdyasser you should be able to assign yourself in the top right. I'll assign it to you for now
Describe the bug
The codebase uses lots of
model.id!
e.g. https://github.com/vapor/fluent-kit/blob/main/Sources/FluentKit/Model/Model%2BCRUD.swift#L74, and if a model was newly created using a custominit
without generating theid
yet (e.g. on iOS client), accessingmodel.id!
causes instant crash. Instead, we shouldguard
and throw an exception.To Reproduce
init
, and don't manually assign a value toid
model.delete()
Expected behavior
An exception should be thrown as
delete
etc are throwing functionsEnvironment
I'm using
fluent-sqlite-driver
ofmain
branch via SPM in Xcode on iOS 15.4, which depends onFluentKit