Fix a minor issue caused by recent commits where sql was not generated correctly