Looking for a solution @
MDL-47509, it was detected that the reserved-word "uid" was also being used in badges.
I've not verified it, neither seems to fail any unit test. But I'm 99% sure it leads to problems under Oracle.
And there are occurrences both in 2.7 and master.
So this is about:
1) get rid of all those "uid" uses in badges.
2) hopefully get some simple unit test covering some of those queries so we can ensure they are working under all DBs.