Christopher H. Laco wrote:
> Christopher H. Laco wrote:
>> While working on the Handel conversion to DBIC, I've come across the
>> need to have my resultsets always be "Carts" and "Items" regardless of
>> what the actual packages are named.
>>
>> For now, I've simply created a register_cart_classes() method that calls
>> register_class and sets the appropriate generic $monkier. Unfortunately,
>> that means I can't use load_classes() and whatever magic it may contain.
>>
>> Would there be any interest in adding something to ResultSource:
>>
>> package My::Schema::Foo;
>> __PACKAGE__->table('foo');
>> __PACKAGE__->alias('Cart')
>> # or
>> __PACKAGE__->moniker('Cart');
>>
>>
>> Then, after load_classes and connect(), we have:
>>
>> $schema->resultset('Cart')...
>>
>> instead of:
>>
>> $schema->resultset('Foo')...
>>
>>
>> -=Chris
>
> Upon some direction from mst, I've started working on this.
>
> The initial plan was to change $resultsource->name to
> $resultsource->table_name, then use $resultsource->name like so:
>
> package MySchema::MyTable;
> __PACKAGE__->table('my_table');
> __PACKAGE__->name('Table');
> 1;
>
> # later in in the schema...
> $schema->resultset('Table')->find(1);
>
>
> After getting so far, it became apparent that more than a few things use
> $resultsource->name, including but not limited to:
>
>> lib\DBIx\Class\ResultSet.pm(301): "Unknown key $attrs->{key} on '" .
>> $self->result_source->name . "'"
>> lib\DBIx\Class\ResultSet.pm(1221): "search_related: result source '" .
>> $self->result_source->name .
>> lib\DBIx\Class\ResultSource.pm(265): $self->throw_exception("No such column
>> $col on table " . $self->name)
>> lib\DBIx\Class\ResultSource.pm(301): $self->throw_exception("No such column
>> $col on table " . $self->name)
>> lib\DBIx\Class\ResultSource.pm(647): $self->throw_exception( $self->name . "
>> has no such relationship '$pre'" )
>> lib\DBIx\Class\CDBICompat\LazyLoading.pm(32): $self->result_source->name,
>> [EMAIL PROTECTED],
>> lib\DBIx\Class\Storage\DBI\Oracle.pm(34): $sth->execute( uc($source->name) );
>> lib\DBIx\Class\Storage\DBI\Oracle.pm(38): croak "Unable to find a sequence
>> INSERT trigger on table '" . $source->name . "'.";
>> lib\DBIx\Class\Storage\DBI\Pg.pm(21): my ($schema,$table) = $source->name =~
>> /^(.+)\.(.+)$/ ? ($1,$2)
>> lib\DBIx\Class\Storage\DBI\Pg.pm(22): : (undef,$source->name);
>> lib\SQL\Translator\Parser\DBIx\Class.pm(53): name => $source->name,
>> lib\SQL\Translator\Parser\DBIx\Class.pm(93): my $rel_table =
>> $source->related_source($rel)->name;
>> lib\SQL\Translator\Producer\DBIx\Class\File.pm(71): my $tname = $table->name;
>> lib\SQL\Translator\Producer\DBIx\Class\File.pm(85): { { $_->name => {
>> lib\SQL\Translator\Producer\DBIx\Class\File.pm(86): name =>
>> $_->name,
>> lib\SQL\Translator\Producer\DBIx\Class\File.pm(113): my @pk = map { $_->name
>> } ($pk->fields);
>> lib\SQL\Translator\Producer\DBIx\Class\File.pm(124): #
>> $cont->fields->[0]->name . "', '" .
>> lib\SQL\Translator\Producer\DBIx\Class\File.pm(127):
>> $tableextras{$table->name} .= "\n__PACKAGE__->belongs_to('" .
>> lib\SQL\Translator\Producer\DBIx\Class\File.pm(128):
>> $cont->fields->[0]->name . "', '" .
>> lib\SQL\Translator\Producer\DBIx\Class\File.pm(132): "get_" . $table->name.
>> "', '" .
>> lib\SQL\Translator\Producer\DBIx\Class\File.pm(133): "${dbixschema}::" .
>> $table->name. "', '" .
>> lib\SQL\Translator\Producer\DBIx\Class\File.pm(134):
>> $cont->fields->[0]->name . "');";
>> lib\SQL\Translator\Producer\DBIx\Class\File.pm(139):
>> $tableoutput{$table->name} .= $output;
>
>
>
> So, the question now becomes, what does everything think?
>
> Should we leave ->name alone, and make something new like
> result_source_name(), or do we forge ahead with changing the meaning of
> what ->name() returns?
>
> -=Chris
> The more I think about this, the more I don't like it. I think adding table_name, and having from() return table_name is a good thing. But I think name should just return what it always has. name() can mean different things to different modules, in different parts of the dist. I'd personally much rather see source_name(). That's a little more clear IMHO on what it will return. ? -=Chris
signature.asc
Description: OpenPGP digital signature
_______________________________________________ List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class Wiki: http://dbix-class.shadowcatsystems.co.uk/ IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
