Fix bug in generating where statements for tables with composite keys