Closed rafiki270 closed 4 years ago
Quick fix is to rename the id
column (coding part) of your JOIN model to something like join_id
:
/// Join table between Apps and Tags
public final class BuildTag: PostgreSQLUUIDModel {
public typealias Left = Build
public typealias Right = Tag
public static var leftIDKey: WritableKeyPath<BuildTag, DbIdentifier> {
return \.buildId
}
public static var rightIDKey: WritableKeyPath<BuildTag, DbIdentifier> {
return \.tagId
}
public var id: UUID?
public var buildId: UUID
public var tagId: UUID
enum CodingKeys: String, CodingKey {
case id = "join_id"
case buildId = "build_id"
case tagId = "tag_id"
}
}
I'm seeing the same thing in very similar code.
The issue is described more in-depth here: https://github.com/vapor/fluent-postgres-driver/pull/114
To solve this problem you can run releaseCachedConnections(on:...)
causing the schema lookup information to be refreshed.
This is no longer a problem in Fluent 4 since unambiguous column aliases are used, i.e.:
SELECT id AS todos_id FROM todos
In case of:
I get
BuildTag.id
in my result objects