fixed issue when generating associative table data with optional
relation