From: Peter Rabbitson Date: Mon, 2 May 2016 11:35:40 +0000 (+0200) Subject: Explicit exception clarifying that $rsrc->from() is not a setter X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b8e0ecca212fd1ad779865238c8bd4b3c2f62e3f;p=dbsrgits%2FDBIx-Class.git Explicit exception clarifying that $rsrc->from() is not a setter This has always been the case, but previously from('foo') would just eat the arguments silently --- diff --git a/Changes b/Changes index e288bb2..edafbfe 100644 --- a/Changes +++ b/Changes @@ -23,6 +23,8 @@ Revision history for DBIx::Class mismatches between your codebase and data source - Calling the set_* many-to-many helper with a list (instead of an arrayref) now emits a deprecation warning + - Calling the getter $rsrc->from("argument") now throws an exception + instead of silently discarding the argument * New Features - When using non-scalars (e.g. arrays) as literal bind values it is no diff --git a/lib/DBIx/Class/ResultSource/Table.pm b/lib/DBIx/Class/ResultSource/Table.pm index b6add2a..f1900f9 100644 --- a/lib/DBIx/Class/ResultSource/Table.pm +++ b/lib/DBIx/Class/ResultSource/Table.pm @@ -26,7 +26,10 @@ Returns the FROM entry for the table (i.e. the table name) =cut -sub from { $_[0]->name } +sub from { + $_[0]->throw_exception('from() is not a setter method') if @_ > 1; + $_[0]->name; +} =head1 FURTHER QUESTIONS? diff --git a/lib/DBIx/Class/ResultSource/View.pm b/lib/DBIx/Class/ResultSource/View.pm index 4694c87..846bcf6 100644 --- a/lib/DBIx/Class/ResultSource/View.pm +++ b/lib/DBIx/Class/ResultSource/View.pm @@ -148,9 +148,11 @@ or the SQL as a subselect if this is a virtual view. =cut sub from { - my $self = shift; - return \"(${\$self->view_definition})" if $self->is_virtual; - return $self->name; + $_[0]->throw_exception('from() is not a setter method') if @_ > 1; + $_[0]->is_virtual + ? \( '(' . $_[0]->view_definition .')' ) + : $_[0]->name + ; } =head1 OTHER METHODS