Hi! I have a model which has multiple properties with the same field ID.
This is due to one of the field being the id of the model, and the other being an @Parent relationship to another table. I want both my tables to have the same ID.
Before FluentKit 1.42.2 version, it worked great, now I get the error column "user_id" specified more than once.
Specifically, the generated SQL request is
final class ConsumerProfile : Model {
static let schema = "consumer_profiles"
@ID(custom: "user_id", generatedBy: .user)
var id: UUID?
@Parent(key: "user_id")
var user: User
}
final class User : Model {
static let schema = "users"
@ID
var id: UUID?
}
Create a User
Create a ConsumerProfile
Example:
let user = User()
try await user.save(on: db)
let consumer = ConsumerProfile()
consumer.id = try user.requireID()
try await consumer.save(on: db)
Expected behavior
FluentKit should detect the same column ID is used twice and remove one of them if the values are equal, or throw if they are not.
Environment
Vapor Framework version: 4.77.0
Vapor Toolbox version: 18.7.1
OS version: macOS 14.0 Beta (23A5276g)
Additional context
I have explicitly tested, with FluentKit 1.42.1 I have the expected behavior, with FluentKit 1.42.2 I do not, all other versions of my dependencies being equal.
Describe the bug
Hi! I have a model which has multiple properties with the same field ID. This is due to one of the field being the
id
of the model, and the other being an@Parent
relationship to another table. I want both my tables to have the same ID.Before FluentKit
1.42.2
version, it worked great, now I get the errorcolumn "user_id" specified more than once
. Specifically, the generated SQL request isAs we can see, the
user_id
column is there twice.To Reproduce
Create a model like so:
Example:
Expected behavior
FluentKit should detect the same column ID is used twice and remove one of them if the values are equal, or throw if they are not.
Environment
Additional context
I have explicitly tested, with FluentKit
1.42.1
I have the expected behavior, with FluentKit1.42.2
I do not, all other versions of my dependencies being equal.