Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using IDProperty of type Int64 fails to create a database generated value #544

Open
tkrajacic opened this issue Jan 2, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@tkrajacic
Copy link

Describe the bug

When using an Int64 as a primary key, and wanting to let the database generate it automatically, FluentKit fails to recognize this as autogenerated id.

@ID(custom: .id) public var id: Int64?

Using a regular Int type works because this case is specifically handled in FluentKit

@propertyWrapper
public final class IDProperty<Model, Value>
    where Model: FluentKit.Model, Value: Codable
{
    public enum Generator {
        case user
        case random
        case database

        static func `default`<T>(for type: T.Type) -> Generator {
            if T.self is RandomGeneratable.Type {
                return .random
            } else if T.self == Int.self { // <- here
                return .database
            } else {
                return .user
            }
        }
    }
// …
}

Expected behavior

Primary keys of type Int64 should work.

Environment

  • Vapor Framework version: 4.67.5
  • Vapor Toolbox version: 18.6.0
  • OS version: 12.6.2
@tkrajacic tkrajacic added the bug Something isn't working label Jan 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant