dbsrgits / dbix-class-schema-loader

Official GitHub remote for git.shadowcat.co.uk DBIx-Class-Schema-Loader.git
http://dbix-class.org/
11 stars 34 forks source link

Optionally warn when a relationship is redefined [PATCH] [rt.cpan.org #73876] #49

Open rabbiveesh opened 1 year ago

rabbiveesh commented 1 year ago

Migrated from rt.cpan.org#73876 (status was 'open')

Requestors:

Attachments:

From timb@cpan.org on 2012-01-10 12:46:34 :

We've been using Schema::Loader for years on a large postgresql database. Over the years 
we've had to add manual relationships to the generated schema files because S:L was missing 
them for various reasons (often because they weren't declared in the database itself yet).

Now our schema is more complete and S:L is better at finding relationships and is adding 
them to the generated schema files. However, they're being silently overridden by the manual 
relationships we added previously.  The old manually added relationships are usually 
incomplete and sometimes plain wrong.

The attached patch makes it easy to identify redefined relationships. It carps is a relationship 
is redefined while DBIC_TRACE is set.

Some other env var or control mechanism could be used, I just picked DBIC_TRACE as an easy 
option. (I'd be happy if warnings were the default and were silenced by adding an attribute 
like is_redefintion=>1 to the new relationship definition.)

From rkitover@cpan.org on 2012-01-10 13:03:54 :

Committed to topic/rel_redef_warn

From ribasushi@leporine.io on 2012-01-11 08:41:44 :

On Tue, Jan 10, 2012 at 07:46:36AM -0500, Tim_Bunce via RT wrote:
> Tue Jan 10 07:46:34 2012: Request 73876 was acted upon.
> Transaction: Ticket created by TIMB
>        Queue: DBIx-Class
>      Subject: Optionally warn when a relationship is redefined [PATCH]
>    Broken in: (no value)
>     Severity: Unimportant
>        Owner: Nobody
>   Requestors: TIMB@cpan.org
>       Status: new
>  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=73876 >
> 
> 
> We've been using Schema::Loader for years on a large postgresql database. Over the years 
> we've had to add manual relationships to the generated schema files because S:L was missing 
> them for various reasons (often because they weren't declared in the database itself yet).
> 
> Now our schema is more complete and S:L is better at finding relationships and is adding 
> them to the generated schema files. However, they're being silently overridden by the manual 
> relationships we added previously.  The old manually added relationships are usually 
> incomplete and sometimes plain wrong.
> 

Newer versions of S::L are detecting such cases and issue the corresponding warnings.
If your S::L is upgraded, and you are not seeing those - this is a bug in S::L itself.

The other consideration to take is that silent overrides can happen on column accessors,
in adition to relationship accessors. S::L is supposed to detect this as well (also
it should detect static compile-time sub{}s).

As far as the patch is concerned - I am really wary of tying warn-toggle semantics
into DBIC_TRACE itself. I will be back on IRC next Monday, we can discuss options
then.

Cheers