vapor/fluent-mysql-driver

Support saving String-backed, Codable-conforming enums to MySQL DB w/Fluent...

Darchmare opened this issue · 1 comments

I am attempting to save a String-backed Codable-conforming enum, exposed as a property of a model struct, to a MySQL DB with Fluent.

It is failing with the error Cannot serialize Status to MySQLData.

The enum in question:

enum Status: String, Content, ReflectionDecodable, MySQLColumnDefinitionStaticRepresentable {
	static var mySQLColumnDefinition: MySQLColumnDefinition {
		return .varChar(length: 255)
	}

	case active = "active"
	case expired = "expired"
	case confirmed = "confirmed"

	static func reflectDecoded() throws -> (Status, Status) {
		return (.active, .expired)
	}
}

I've tried this both with and without conforming to MySQLColumnDefinitionStaticRepresentable.

I've checked a couple of times on Slack and nobody seems to have any idea about why this isn't working, so I'm assuming it's a bug.

Totally agree, we need to make this easier. I have a couple ideas on how to do it, thanks!