testing495
testing495

Reputation: 272

GORM not returning results, but when I run the SQL query in my database client, records come back

My GORM query looks a little like this:

selectCallSQL = "SELECT * from callautomation_schedule WHERE id = ?"
testSelect = "SELECT * FROM callautomation_schedule WHERE next_planned_call > date_trunc('minute', now())"


func SelectCall(id int) *CallSchedule{
    var result CallSchedule
    connection.Raw(selectCallSQL, id).Scan(&result)
    return &result
}

func SelectCall2() *CallSchedule{
    var result CallSchedule
    connection.Raw(testSelect).Scan(&result)
    return &result
}

The first function returns a result as expected, however, the second function does not.

If I run the testSelect SQL in my database client, I do get a result. Why is this happening?

Upvotes: 0

Views: 886

Answers (1)

testing495
testing495

Reputation: 272

The issue I discovered was with my connection string and column setup. I was using the type TIMESTAMP NO TIMEZONE in my table schema, but in my connection string, I was connecting via the Asia Timezone.

Annoying bug, but fixed now!

Upvotes: 2

Related Questions