[Jifty-commit] r1594 - Jifty-DBI/trunk/lib/Jifty/DBI
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Mon Jul 17 01:22:34 EDT 2006
Author: audreyt
Date: Mon Jul 17 01:22:34 2006
New Revision: 1594
Modified:
Jifty-DBI/trunk/lib/Jifty/DBI/Schema.pm
Log:
* Jifty::DBI::Schema - defer initialization for columns created via the
schema{} wrapper, so that users can continue to define column names
that overlaps with the helper functions, such as "label" and "type".
Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Schema.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Schema.pm (original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Schema.pm Mon Jul 17 01:22:34 2006
@@ -77,7 +77,13 @@
# Unimport all our symbols from the calling package.
foreach my $sym (@EXPORT) {
no strict 'refs';
- undef *{"$from\::$sym"};
+ undef *{"$from\::$sym"}
+ if \&{"$from\::$sym"} == \&$sym;
+ }
+
+ # Then initialize all columns
+ foreach my $column (sort keys %{$from->COLUMNS}) {
+ $from->_init_methods_for_column($from->COLUMNS->{$column});
}
};
@@ -155,7 +161,14 @@
$from->COLUMNS->{$name} = $column;
- $from->_init_methods_for_column($column);
+
+ # Heuristics: If we are called through Jifty::DBI::Schema,
+ # then we know that we are going to initialize methods later
+ # through the &schema wrapper, so we defer initialization here
+ # to not upset column names such as "label" and "type".
+ return if caller(1) eq __PACKAGE__;
+
+ $from->_init_methods_for_column($column)
}
=head2 refers_to
More information about the Jifty-commit
mailing list