Fix some weird behavior with PostgreSQL