Problem With Uniquemulticolumnvalidator And Defaultscope

Hi guys

I am using a defaultScope with alias. The defaultScope filters the records based on records in a related table.

One of my validation rules uses the extension uniqueMultiColumnValidator.

The SQL generated by this extension’s




$models=$model->findAll($criteria)



statement uses the alias of the defaultScope correctly, but it does not insert a ‘t.’ before the default model’s columns - resulting in ambiguous fields.

I added this line to the extension:




$columnName = $model->getTableAlias( false, false ) . "." . $columnName;



but it results in Column not found: 1054 Unknown column ‘t.business_id’ in ‘where clause’.

It seams that lots of people have similar problems with scopes and ambiguity. Is it better to re-design your DB so that you have multiple databases - but without the need for scopes?

I found a possible reason for the error:

The defaultScope and the validator should use the same alias for the table, since they are working together to produce one sql statement.