Fixed issue where the generated output was incorrectly referencing the wrong table for associations.
Added tests for foreign key association access.