Jesse, I'm working on a problem I've discovered in the V-M branch. I've attached a patch that contains a new bootstrap.t test and modified Bootstrap.pm for TestApp::DatabaseBackedModels to reveal the basic issue. But here's the jist. The patch basically modifies the existing boostrapper to add an additional "Warehouse" model similar to these declared models:
package Warehouse;
schema {
column location => type is 'text';
column widgets => references WidgetCollection by 'warehouse';
};
package Widget;
schema {
column name => type is 'text';
column inventory => type is 'int';
column warehouse => references Warehouse;
};
This code when used works fine until you try to call the "widgets" method of
a "Warehouse" object. When you do that you get:
WARN - DBD::SQLite::db prepare failed: no such column: widgets(1) at
dbdimp.c line 271 at /Library/Perl/5.8.6/Jifty/DBI/Handle.pm line 474.
WARN - TestApp::DatabaseBackedModels::Handle=HASH(0x1f69ea8) couldn't
prepare the query 'SELECT widgets FROM warehouses WHERE id = ?'no such
column: widgets(1) at dbdimp.c line 271
As you can see the anonymous subroutine used to define "widgets" is
incorrectly using a call to __value() to fetch the value rather than using
_collection_value() as it should. I've not pinned this all the way down yet,
but I'm speculating that the issue is that the "widgets" column is being
defined prior to "WidgetCollection" becoming available inside
Jifty::ClassLoader::require_classes_from_database().
What I don't know is how to fix it, if this is indeed the case. I'm
currently working my way through Jifty::DBI::Schema to understand how the
_init_column() method and related code works to see if I can bring the same
or similar logic into the class loader, but I'd be grateful for some advice.
Cheers,
Andrew
databasebackedmodels-load-order-problem.patch
Description: Binary data
_______________________________________________ jifty-devel mailing list [email protected] http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel
