Skip to content

Missing row on execution #371

@fairking

Description

@fairking

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions