Open
Description
Describe the bug
I can't use enums as dictionary keys.
To Reproduce
Example:
enum MyEnum: String, Codable {
case one
}
final class MyModel: Model {
static var schema: String = "tests"
@ID(key: .id)
var id: UUID?
@Field(key: "test")
var test: [MyEnum : Float]
}
struct CreateMigration: Migration {
func prepare(on database: Database) -> EventLoopFuture<Void> {
return database.schema(MyModel.schema)
.id()
.field("test", .dictionary(of: .float), .required)
.create()
}
func revert(on database: Database) -> EventLoopFuture<Void> {
return database.schema(MyModel.schema).delete()
}
}
let test = MyModel()
test.test = [.one: Float(1)]
test.save(on: app.db)
Steps to reproduce the behavior:
- Execute migration
- Execute MyModel creation
- See error "Array does not contain all: TEXT" at PostgresDataEncoder
Expected behavior
Create database schema correctly
Environment
- Vapor Framework version: 4.35.0
- Vapor Toolbox version: 18.3.0
- OS version: macOS Big Sur 11.2.1 (20D74)