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

MysqlNIO is missing MySQLData conformance for Data #106

Open
JetForMe opened this issue Mar 11, 2024 · 0 comments
Open

MysqlNIO is missing MySQLData conformance for Data #106

JetForMe opened this issue Mar 11, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@JetForMe
Copy link
Contributor

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

@JetForMe JetForMe added the bug Something isn't working label Mar 11, 2024
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

2 participants