I have this postgres sql query:
select * from stats where athlete_id = 5
That will return, as you'd imagine, all the stats for each athlete of id 5
So far so normal.
However I just noticed that for athlete_id above 110, it returns the stats rows in the opposite order.
So for athlete_id = 110 the 'id' column comes out like this which is what i'm used to:
2325
2401
2482
2537
2592
2647
...
etc. Each stats table row in order by id.
Then if you select 111, it comes out like this:
5652
5610
5569
5528
5487
5437
5387
5336
...
How is that even possible? This is all doing the queries inside the pgadmin interface. There's no additional where clauses, only the one I've stated, i.e. WHERE athlete_id = 111
What? I've been making all sorts of code changes but what on earth would cause this within pgaadmin /pgsql ?
What happened between 110 & 111? Lots and lots of refactoring and code changes inside rails, but no actual direct SQL manipulation. Yes I realise the answer might be in there, but I don't know how to look, as this is not in the rails app - this is pure SQL via pgadmin, so something must have been done in postgres - I need to understand what that might be or I'm at a loss to debug.
Any ideas? In rails, things like:
Athlete.stats.last.score return the 'first' row instead of the 'last' row, completely screwing up the application, but only for athletes with an id above 110!
Totally confused!