Fix a couple of failing tests.
Improve generateAssociationQuery():

* bail early when $linkModel is Null (BC for now).
* move SQL fields warmup and SQL statement building to its own functions
 (it will payoff later improving self documentation and readability).
* make assignments and function calls only when needed (depending on the
 association type).
Explicitly build SQL statements, calling buildAssociationQuery().