Skip Menu |
 

This queue is for tickets about the SQL-Abstract-Limit CPAN distribution.

Report information
The Basics
Id: 26558
Status: open
Priority: 0/
Queue: SQL-Abstract-Limit

People
Owner: Nobody in particular
Requestors: col [...] evolone.org
Cc:
AdminCc:

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



Subject: Spaces in column name fails with order_by
Date: Sun, 22 Apr 2007 23:22:51 -0700
To: bug-SQL-Abstract-Limit [...] rt.cpan.org
From: col <col [...] evolone.org>
Download (untitled) / with headers
text/plain 1013b
I think the split foreach my $spec ( @order ) { my @spec = split ' ', $spec; croak( "bad column order spec: $spec" ) if @spec > 2; push( @spec, 'ASC' ) unless @spec == 2; my ( $col, $up ) = @spec; # or maybe down $up = uc( $up ); croak( "bad direction: $up" ) unless $up =~ /^(?:ASC|DESC)$/; $order_by_up .= ", $col $up"; my $down = $up eq 'ASC' ? 'DESC' : 'ASC'; $order_by_down .= ", $col $down"; } is causing me grief. My spec is passed with: order_by =>\'"Invoice #" DESC', because I have quoting turned on for the column names with spaces. Using DBIx::Class. Error is SCALAR0xXXXXXX is a bad column name, or the error above when I don't use the leading \. Works as it should unless I'm trying to do paged resultsource. So, I don't know what actually causes it. Cheers, -- |\ /| | | ~ ~ | \/ | |---| `|` ? | |ichael | |iggins \^ / michael.higgins[at]evolone[dot]org
Subject: Re: [rt.cpan.org #26558] AutoReply: Spaces in column name fails with order_by
Date: Mon, 23 Apr 2007 16:06:10 -0700
To: bug-SQL-Abstract-Limit [...] rt.cpan.org
From: col <col [...] evolone.org>
Download (untitled) / with headers
text/plain 3.2k
On Mon, 23 Apr 2007 02:25:33 -0400 "Bugs in SQL-Abstract-Limit via RT" <bug-SQL-Abstract-Limit@rt.cpan.org> wrote: Show quoted text
> > Greetings, > > This message has been automatically generated in response to the > creation of a trouble ticket regarding: > "Spaces in column name fails with order_by", > a summary of which appears below. > > There is no need to reply to this message right now. Your ticket has > been assigned an ID of [rt.cpan.org #26558]. Your ticket is > accessible on the web at: > > http://rt.cpan.org/Ticket/Display.html?id=26558 > > Please include the string: > > [rt.cpan.org #26558] > > in the subject line of all future correspondence about this issue. To > do so, you may reply to this message. > > Thank you, > bug-SQL-Abstract-Limit@rt.cpan.org > > ------------------------------------------------------------------------- > I think the split > > foreach my $spec ( @order ) > { > my @spec = split ' ', $spec; > croak( "bad column order spec: $spec" ) if @spec > 2; > push( @spec, 'ASC' ) unless @spec == 2; > my ( $col, $up ) = @spec; # or maybe down > $up = uc( $up ); > croak( "bad direction: $up" ) unless $up =~ /^(?:ASC|DESC)$/; > $order_by_up .= ", $col $up"; > my $down = $up eq 'ASC' ? 'DESC' : 'ASC'; > $order_by_down .= ", $col $down"; > } > > is causing me grief. My spec is passed with: > > order_by =>\'"Invoice #" DESC', > > because I have quoting turned on for the column names with spaces. > Using DBIx::Class. > > Error is SCALAR0xXXXXXX is a bad column name, or the error above when > I don't use the leading \. > > Works as it should unless I'm trying to do paged resultsource. So, I > don't know what actually causes it. > > Cheers, >
Well, I spent a chunk of the workday figuring this out. Indeed, the problem is with that split. You (I think) need to have a further case when the elements in @spec is exactly one scalar reference. When the order_by directive has a quoted column name, it gets passed by reference, according to DBIx-Class-Resultset... so, foreach my $spec ( @order ) { my @spec; my ($col, $up); if (! ref $spec){ @spec = split ' ', $spec; Carp::croak( "bad column order spec: $spec" ) if @spec > 2; push( @spec, 'ASC' ) unless @spec == 2; ( $col, $up ) = @spec; # or maybe down }else { my $lastspace = (rindex $$spec, ' ') +1; $col = substr $$spec, 0, $lastspace; $up = substr $$spec, $lastspace; } $up = uc( $up ); Carp::croak( "bad direction: $up" ) unless $up =~ /^(?:ASC|DESC)$/; $order_by_up .= ", $col $up"; my $down = $up eq 'ASC' ? 'DESC' : 'ASC'; $order_by_down .= ", $col $down"; } s/^,/ORDER BY/ for ( $order_by_up, $order_by_down ); return $order_by_up, $order_by_down; } ... fixed the problem for me, so far... sloppy though it may be. Does that illustrate the problem enough? I don't know what other expected behavior this would break, but I'd love to know I'll not have to worry about the next release breaking my program either. Cheers, -- |\ /| | | ~ ~ | \/ | |---| `|` ? | |ichael | |iggins \^ / michael.higgins[at]evolone[dot]org
Download (untitled) / with headers
text/plain 3.4k
On Mon Apr 23 19:08:57 2007, col@evolone.org wrote: Show quoted text
> On Mon, 23 Apr 2007 02:25:33 -0400 > "Bugs in SQL-Abstract-Limit via RT" > <bug-SQL-Abstract-Limit@rt.cpan.org> wrote: >
> > > > Greetings, > > > > This message has been automatically generated in response to the > > creation of a trouble ticket regarding: > > "Spaces in column name fails with order_by", > > a summary of which appears below. > > > > There is no need to reply to this message right now. Your ticket has > > been assigned an ID of [rt.cpan.org #26558]. Your ticket is > > accessible on the web at: > > > > http://rt.cpan.org/Ticket/Display.html?id=26558 > > > > Please include the string: > > > > [rt.cpan.org #26558] > > > > in the subject line of all future correspondence about this issue. To > > do so, you may reply to this message. > > > > Thank you, > > bug-SQL-Abstract-Limit@rt.cpan.org > > > >
------------------------------------------------------------------------- Show quoted text
> > I think the split > > > > foreach my $spec ( @order ) > > { > > my @spec = split ' ', $spec; > > croak( "bad column order spec: $spec" ) if @spec > 2; > > push( @spec, 'ASC' ) unless @spec == 2; > > my ( $col, $up ) = @spec; # or maybe down > > $up = uc( $up ); > > croak( "bad direction: $up" ) unless $up =~ /^(?:ASC|DESC)$/; > > $order_by_up .= ", $col $up"; > > my $down = $up eq 'ASC' ? 'DESC' : 'ASC'; > > $order_by_down .= ", $col $down"; > > } > > > > is causing me grief. My spec is passed with: > > > > order_by =>\'"Invoice #" DESC', > > > > because I have quoting turned on for the column names with spaces. > > Using DBIx::Class. > > > > Error is SCALAR0xXXXXXX is a bad column name, or the error above when > > I don't use the leading \. > > > > Works as it should unless I'm trying to do paged resultsource. So, I > > don't know what actually causes it. > > > > Cheers, > >
> > Well, I spent a chunk of the workday figuring this out. Indeed, the > problem is with that split. You (I think) need to have a further case > when the elements in @spec is exactly one scalar reference. > > When the order_by directive has a quoted column name, it gets passed by > reference, according to DBIx-Class-Resultset... so, > > foreach my $spec ( @order ) > { > > my @spec; > my ($col, $up); > if (! ref $spec){ > @spec = split ' ', $spec; > Carp::croak( "bad column order spec: $spec" ) if @spec > 2; > push( @spec, 'ASC' ) unless @spec == 2; > ( $col, $up ) = @spec; # or maybe down > }else { > my $lastspace = (rindex $$spec, ' ') +1; > $col = substr $$spec, 0, $lastspace; > $up = substr $$spec, $lastspace; > } > $up = uc( $up ); > Carp::croak( "bad direction: $up" ) unless $up > =~ /^(?:ASC|DESC)$/; $order_by_up .= ", $col $up"; > my $down = $up eq 'ASC' ? 'DESC' : 'ASC'; > $order_by_down .= ", $col $down"; > } > > s/^,/ORDER BY/ for ( $order_by_up, $order_by_down ); > > return $order_by_up, $order_by_down; > } > > ... fixed the problem for me, so far... sloppy though it may be. > > Does that illustrate the problem enough? > > I don't know what other expected behavior this would break, but I'd love > to know I'll not have to worry about the next release breaking my > program either. > > Cheers, > >
Has this been resolved when used with DBIx::Class? If not please open an RT ticket against DBIC, so we can add a workaround.
Subject: Re: [rt.cpan.org #26558] Spaces in column name fails with order_by
Date: Wed, 3 Jun 2009 08:51:17 -0700
To: bug-SQL-Abstract-Limit [...] rt.cpan.org
From: col <col [...] evolone.org>
Download (untitled) / with headers
text/plain 1.5k
On Tue, 02 Jun 2009 03:19:18 -0400 "Peter Rabbitson via RT" <bug-SQL-Abstract-Limit@rt.cpan.org> wrote: Show quoted text
[...] Show quoted text
> > Has this been resolved when used with DBIx::Class? If not please open > an RT ticket against DBIC, so we can add a workaround.
What DBIC needs is an order by test on a column with spaces in the name, not more RT tickets regarding same. '-) Can't you just add one to the test suite in the repo? It seems absolutely insane for me to test this every time it comes up for a review. (Yeah, I might be the only person in the entire world who inherited a stupidly-designed database... NOT) Please: just put a column with spaces, make it primary key if you wish, order by it. The problem is very well described, wouldn't you agree? You folks have access to the code repo. You put the simple test in, and then it is a permanent thing and gets tested on every revision, right? Anyway, if you don't agree that a test (failing or otherwise) is the *right thing to do* (Matt tried to get me to do it but frankly I see a slippery slope there and I'm too old to give my sleep time to perl any more), then, sure, I'll have a look. Also, Marc Mims did some testing against my SQL Server flavour "2000" for some of the ODBC MSSQL last_insert_id stuff... You, too, could be set up for that... if you want to test against it at some point on your own. Please let me know your thoughts. Cheers, -- |\ /| | | ~ ~ | \/ | |---| `|` ? | |ichael | |iggins \^ / michael.higgins[at]evolone[dot]org


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.