do not produce bad query when no groups, fixes #27