Skip Menu |

This queue is for tickets about the HTML-FormFu-Model-DBIC CPAN distribution.

Report information
The Basics
Id: 41720
Status: rejected
Priority: 0/
Queue: HTML-FormFu-Model-DBIC

People
Owner: Nobody in particular
Requestors: felix.ostmann [...] thewar.de
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.03007
Fixed in: (no value)



Subject: Ambiguous columnname for many-to-many relationships using default_values()
our db-schema is not the same as the test-db, we use only _id names for all id-columns in every table, also in the many-to-many-linking-table. Schema: CREATE TABLE users ( user_id INTEGER PRIMARY KEY NOT NULL, name TEXT NOT NULL ); CREATE TABLE bands ( band_id INTEGER PRIMARY KEY NOT NULL, band TEXT NOT NULL ); CREATE TABLE user2bands ( user_id INTEGER NOT NULL, band_id INTEGER NOT NULL, PRIMARY KEY (user_id, band_id) ); So when we call $form->model->default_values($user) we get following error: ERROR 1052 (23000): Column 'band_id' in field list is ambiguous The executes query is: SELECT band_id FROM user2bands me JOIN bands band ON ( band.band_id = me.band_id ) WHERE ( me.user_id = 31 ); It should be SELECT me.band_id FROM ... when we change the row ~202 in HTML/FormFu/Model/DBIC.pm from: my @defaults = $dbic->$name->get_column($col)->all; to: my @defaults = $dbic->$name->get_column("me.$col")->all; it works currently, but i am not sure if this is the right way.
Hi, If I make that change, the test suite starts failing. I think it should really be "band.band_id" - not "me.band_id" - it only works for you because both tables have the same named column. I think the correct fix for this is to add the config: model_config: default_column: 'band.band_id' on the appropriate formfu field.