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

Date filters fail when TimeStamp.format has un underlying value that isn't Date #566

Open
IanKeen opened this issue Jun 4, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@IanKeen
Copy link
Member

IanKeen commented Jun 4, 2023

Describe the bug

The @Timestamp property wrapper has an optional format: parameter which determines how the underlying value is stored.
Some formats (like .iso8601) result in types like String however when trying to query these properties in a type safe manner like:

.filter(\Model.$iso8601Property, >= someDate)

The generated SQL does not perform any allowances for the type mismatch and results in the follow error (and failed query)

operator does not exist: text >= timestamp with time zone

To Reproduce

    final class Item: Codable, Model {
        static let schema = "item"

        @ID(key: .id)
        var id: UUID?

        @Timestamp(key: "created_at", on: .create, format: .iso8601)
        var createdAt: Date?
    }

Then attempt a query like

Item.query(on: db)
   .filter(\.$createdAt >= .distantPast)
   .all()

Expected behavior

I would expect the SQL to convert the right side value to a String so the query is successful

Environment

  • Fluent Framework version: 1.36.1
  • OS version: 13.1 (22C65)
@IanKeen IanKeen added the bug Something isn't working label Jun 4, 2023
@gwynne gwynne self-assigned this Jun 4, 2023
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