Closed PopFlamingo closed 4 years ago
The way I noticed this is that I got errors since my model identifiers aren't named id
.
Hi, I have same problem. It can be fixed if someone agree with this changes in fluent-kit.
Then PostgresReturning
struct can be changed to
private struct PostgresReturning: SQLExpression {
let base: SQLExpression
let idKey: String
init(_ base: SQLExpression, _ idKey: String) {
self.base = base
self.idKey = idKey
}
func serialize(to serializer: inout SQLSerializer) {
self.base.serialize(to: &serializer)
serializer.write(#" RETURNING "\#(idKey)" as "fluentID""#)
}
}
// and change call initializer in _FluentPostgresDatabase extension
expression = PostgresReturning(expression, query.idKey)
Fixed. Thank you for reporting.
I'm not sure to understand exactly how
id
andfluentID
are used by Fluent, but from what I can tell, in:It doesn't seem ok to have
id
hardcoded inRETURNING id as "fluentID"
, instead it should be the name of the primary key of the model, whatever it is.What do you think?