Skip to content

MysqlNIO is missing MySQLData conformance for Data #106

@JetForMe

Description

@JetForMe

Describe the issue

MysqlNIO is missing MySQLData conformance for Data

Vapor version

4.92.4

Operating system and version

macOS 14.3.x

Swift version

5.10

Steps to reproduce

Create an Entity with .data type, and try to write Swift Data to it. It'll end up encoded base64.

Adding the missing conformance fixes it:

import MySQLNIO
import NIOFoundationCompat

extension Foundation.Data: MySQLDataConvertible {
    init?(mysqlData: MySQLData) {
        guard [.blob, .mediumBlob, .longBlob, .tinyBlob].contains(mysqlData.type),
              mysqlData.format == .binary,
              let buffer = mysqlData.buffer else {
            return nil
        }
        self = .init(buffer: buffer)
    }
    var mysqlData: MySQLData? {
        .init(type: .blob, buffer: ByteBufferAllocator().buffer(data: self))
    }
}

Outcome

Can't store Data type.

Additional notes

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions