Reputation: 2847
This query doesn't produce an error but I'm pretty sure EXTRACT(EPOCH FROM relationships.created_at)
isn't doing what it's meant to.
last_check = @user.last_check.to_i
@new_relationships = User.select('"rels_unordered".*')
.from("(#{@rels_unordered.to_sql}) AS rels_unordered")
.joins("
INNER JOIN relationships
ON rels_unordered.id = relationships.character_id
WHERE EXTRACT(EPOCH FROM relationships.created_at) > #{last_check}
GROUP BY relationships.created_at
ORDER BY relationships.created_at DESC
")
How do I check exactly what EXTRACT(EPOCH FROM relationships.created_at)
is producing? The server logs don't show it, they just repeat the query. (At least the logs do show that #{last_check}
correctly produces a number like 1471364015, which is why I think the problem is with the epoch code.)
Upvotes: 1
Views: 33
Reputation: 121
I would just go to mysql and try it out:
SELECT EXTRACT(EPOCH FROM relationships.created_at) FROM relationships limit 0,1;
and see what kind of answer you get. Alter the above to specify a particular record if need be.
A larger problem may be the EPOCH parameter; I'm not sure it's valid. See the mySQL reference for EXTRACT and its parameters.
Upvotes: 1