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

WIP: Demo Codable Enum issue #1124

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ReDetection
Copy link
Contributor

This is not the MR to merge in the current, but more like an issue with submitted demo test case.

The problem: Codable Enum works fine only if saved via Encodable insert, but breaks if I insert column values directly. Compare:

try db.run(table.insert(value)) //this one will read just fine
// INSERT INTO "codable_camel_case" ("camelCaseString") VALUES ('"one"')
try db.run(table.insert(column <- .one)) //this one produces runtime error upon decode
// INSERT INTO "codable_camel_case" ("camelCaseString") VALUES ('one')

I did implement conformance to Value protocol, as you can see in the code, but it seems fromDatatypeValue() function is never used. Instead, it seems to treat it as a JSON, but the second inserted value is of course no valid JSON

@joprice
Copy link

joprice commented Nov 25, 2023

There's also an issue with filtering: When using a String enum as a Value type for a column, it gets wrapped in quotes (its json representation instead of the raw string), but when using it as an Expression, it is not wrapped. This causes well-typed filters to fail to match. Not sure if there's a workaround for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants