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

Empty Set does not encode property #470

Open
grahamburgsma opened this issue Apr 30, 2024 · 0 comments
Open

Empty Set does not encode property #470

grahamburgsma opened this issue Apr 30, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@grahamburgsma
Copy link

Describe the issue

Incorrect column type when encoding an empty Set

Vapor version

4.95

Operating system and version

macOS 14.4

Swift version

Swift Package Manager - Swift 5.10.0-dev

Steps to reproduce

I'm using a Fluent model with a field defined as:

@Field(key: "things")
var things: Set<Thing>

where Thing is an Int enum.

Attempt to create/insert a model where things = [].

Outcome

I get the following error:

[ WARNING ] PSQLError(code: server, serverInfo: [sqlState: 42804, file: parse_target.c, hint: You will need to rewrite or cast the expression., line: 595, message: column "things" is of type integer[] but expression is of type jsonb[], position: 256, routine: transformAssignedExpr, localizedSeverity: ERROR, severity: ERROR], triggeredFromRequestInFile: PostgresKit/PostgresDatabase+SQL.swift, line: 71

Additional notes

It works when set to a non-empty Set.

@grahamburgsma grahamburgsma added the bug Something isn't working label Apr 30, 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

1 participant