On Dec 11, 2007 8:57 AM, Adam Prime <[EMAIL PROTECTED]> wrote: > Now that i've slept i'm wondering if the underlying problem might be > related to the way that defaults are handled in RDBO. That's one thing > that differs between the tables used in the original tests and the table > in the test i submitted.
Yep, that's what it is. From the docs: http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object.pm#load "When loading based on a unique key, unique keys are considered in the order in which they were defined in the metadata for this class. If the object has defined values for every column in a unique key, then that key is used. If no such key is found, then the first key for which the object has at least one defined value is used." Since the "email" unique key is defined first: unique_keys => [ [ 'email' ], [ 'user_name' ], ], when you run this: $o = EatLocal::DB::User->new(user_name => 'adam'); $o->load(); RDBO first checks the "email" column and finds that it does indeed have a defined value: its default value, '' (an empty string): email => { type => 'varchar', default => '', length => 50, not_null => 1 }, Did you use the Loader to make these classes? MySQL tends to offer up empty string default values for non-null character columns, and the Loader dutifully reflects that, having no way to distinguish between "legitimate" empty string default values that you put explicitly in the table definition, or the "bogus" ones that MySQL auto-creates. To avoid this problem, either eliminate the empty string default values manually or automatically (by using the Loader's pre_init_hook to walk the column list and remove empty string defaults) or else pass the "use_key" parameter to load() and specify your key explicitly. -John ------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object