go-rel / rel

:gem: Modern ORM for Golang - Testable, Extendable and Crafted Into a Clean and Elegant API
https://go-rel.github.io/
MIT License
744 stars 58 forks source link

Missing row on execution #371

Open fairking opened 1 month ago

fairking commented 1 month ago

When I run the following query:

    var query = rel.
        Select("c.id", "c.created_time", "c.updated_time", "c.archived", "c.name", "c.description", "^MAX(n.updated_time) last_note_dated", "^AVG(n.score) avg_score").
        From("contacts as c").
        JoinWith("LEFT JOIN", "notes as n", "n.object_id", "c.id", where.Eq("n.archived", false)).
        Where(where.Eq("c.archived", false)).
        Group("c.id", "c.created_time", "c.updated_time", "c.archived", "c.name", "c.description")

The query must return two records, but instead it returns only one. The missing records is the one which has no notes associated. If I copy the query from the instrumentation log and run it manually against the db, it returns two records.

However if I modify the query to (see as):

    var query = rel.
        Select("c.id", "c.created_time", "c.updated_time", "c.archived", "c.name", "c.description", "^MAX(n.updated_time) as last_note_dated", "^AVG(n.score) as avg_score").
        From("contacts as c").
        JoinWith("LEFT JOIN", "notes as n", "n.object_id", "c.id", where.Eq("n.archived", false)).
        Where(where.Eq("c.archived", false)).
        Group("c.id", "c.created_time", "c.updated_time", "c.archived", "c.name", "c.description")

I have got the following error (similar to #370):

sql: Scan error on column index 6, name \"last_note_dated\": unsupported Scan, storing driver.Value type string into type *time.Time", err:(*errors.errorString)(0xc0003f7940)

Looks like something bad is going on when queries got executed. I am probably thinking to quit go-rel as it constantly prevents me from progressing my project.