Skip Menu |
 

This queue is for tickets about the DBIx-Class CPAN distribution.

Report information
The Basics
Id: 69579
Status: rejected
Priority: 0/
Queue: DBIx-Class

People
Owner: Nobody in particular
Requestors: RIZEN [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: aliasing hiccup
I don't know if you want to call this a bug or not, but it caused some minor heartburn so I thought I'd report it. DBIx::Class uses the relationship name as an alias when you join two tables together. In my case I was using a reserved word as a relationship name. The app was working fine until I joined these two tables together, and then it broke for what seemed like no reason until I realized what was going on. In this case I'm writing an order management system, so I used the word "order". In hind site that was not the smartest move on my part. That said, perhaps there could either be a warning about using a reserved as a relationship name, or if someone does use a reserved word, or better yet, we could apply some existing functionality a bit more consistently. I know that if you join a table to itself you get alias_2, and alias_3, etc. If the first alias always had _1 on the end then it would never cause a conflict. So that's my suggestion. Add a _1 to the end of the first instance of an alias.
Download (untitled) / with headers
text/plain 1.3k
On Tue Jul 19 11:14:36 2011, RIZEN wrote: Show quoted text
> I don't know if you want to call this a bug or not, but it caused some > minor heartburn so I > thought I'd report it. > > DBIx::Class uses the relationship name as an alias when you join two > tables together. In my > case I was using a reserved word as a relationship name. The app was > working fine until I > joined these two tables together, and then it broke for what seemed > like no reason until I > realized what was going on. > > In this case I'm writing an order management system, so I used the > word "order". In hind site > that was not the smartest move on my part. That said, perhaps there > could either be a > warning about using a reserved as a relationship name, or if someone > does use a reserved > word, or better yet, we could apply some existing functionality a bit > more consistently. I know > that if you join a table to itself you get alias_2, and alias_3, etc. > If the first alias always had > _1 on the end then it would never cause a conflict. > > So that's my suggestion. Add a _1 to the end of the first instance of > an alias.
Never ever rename stuff to work around lack of quoting. Be it within DBIC or without it. This is a horrible despicable "sweep it under the rug" practice. What you need to do is turn on proper quoting: http://search.cpan.org/~abraxxa/DBIx-Class-0.08193/lib/DBIx/Class/Storage/DBI.pm#quote_names Tagging as rejected.
CC: RIZEN [...] cpan.org
Subject: Re: [rt.cpan.org #69579] aliasing hiccup
Date: Tue, 19 Jul 2011 10:28:33 -0500
To: bug-DBIx-Class [...] rt.cpan.org
From: JT Smith <jt [...] plainblack.com>
Download (untitled) / with headers
text/plain 497b
Show quoted text
> Never ever rename stuff to work around lack of quoting. Be it within > DBIC or without it. This is a horrible despicable "sweep it under the > rug" practice. > > What you need to do is turn on proper quoting: > http://search.cpan.org/~abraxxa/DBIx-Class-0.08193/lib/DBIx/Class/Storage/DBI.pm#quote_names
That seems like a totally reasonable solution. I just didn't know about it. I do have another question then, why is it not on by default? It seems like that can only ever be a good thing.
Subject: Re: [rt.cpan.org #69579] aliasing hiccup
Date: Tue, 19 Jul 2011 11:35:04 -0400
To: "jt [...] plainblack.com via RT" <bug-DBIx-Class [...] rt.cpan.org>
From: Peter Rabbitson <ribasushi [...] cpan.org>
Download (untitled) / with headers
text/plain 945b
On Tue, Jul 19, 2011 at 11:28:54AM -0400, jt@plainblack.com via RT wrote: Show quoted text
> Queue: DBIx-Class > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=69579 > >
> > Never ever rename stuff to work around lack of quoting. Be it within > > DBIC or without it. This is a horrible despicable "sweep it under the > > rug" practice. > > > > What you need to do is turn on proper quoting: > > http://search.cpan.org/~abraxxa/DBIx-Class-0.08193/lib/DBIx/Class/Storage/DBI.pm#quote_names
> > That seems like a totally reasonable solution. I just didn't know about it. I do have another question then, why is it not on by default? It seems like that can only ever be a good thing. >
Backwards compatibility issues (akin to use strict in perl). There is a lot of code out there that uses sql expressions where a column name is expected. Quoting would treat these as malformed columns/malicious attempts and will quote them business as usual.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.