MDL-31987 Assignment module: fix sql for postgres.