Skip Menu |

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

Report information
The Basics
Id: 99455
Status: resolved
Priority: 0/
Queue: SQL-Abstract-More

People
Owner: Nobody in particular
Requestors: valkoles [...] gmail.com
Cc:
AdminCc:

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



Subject: SQL::Abstract::More 1.25 bug
Date: Mon, 13 Oct 2014 01:17:39 -0400
To: bug-SQL-Abstract-More [...] rt.cpan.org
From: val <valkoles [...] gmail.com>
Hi SQL::Abstract::More developer. I've been using this module for a long time. Recently I updated it from 1.10 to 1.25 and got my code not working anymore. Let me quote what kind of changes I had to make to get it working again: ) = $sql -> select( -columns => [ 't3.description|switch_descr', 't1.assigned_by', - q[ concat_ws( ' ', t2.first_name, t2.last_name )|assigned_by_long ], + q[ concat_ws( ' ', t2.first_name, t2.last_name )|assigned_by_long], I think that regexp in newer version got changed and it doesn't account for a trailing space anymore while looking for a column name alias. As a result sql statement mentions non-existing column with '|' in its name. And script dies. Hope it's easily fixable, because I widely use this feature and have many scripts to check and change. Let me know if you need any other information. With best regards, Val
Subject: Re: [rt.cpan.org #99455] AutoReply: SQL::Abstract::More 1.25 bug
Date: Mon, 13 Oct 2014 16:07:46 -0400
To: bug-SQL-Abstract-More [...] rt.cpan.org
From: val <valkoles [...] gmail.com>
Here is one way to fix it: --- /usr/local/perl/lib/site_perl/5.16.1/SQL/Abstract/More.pm 2014-10-03 16:27:50.000000000 -0400 +++ More.pm 2014-10-13 15:48:54.407764200 -0400 @@ -230,9 +230,11 @@ push @post_select, shift @cols while @cols && $cols[0] =~ s/^-//; foreach my $col (@cols) { # extract alias, if any - if ($col =~ /^(.*[^|\s]) # any non-empty string, not ending with ' ' or '|' + if ($col =~ /^\s* # ignore insignificant leading spaces + (.*[^|\s]) # any non-empty string, not ending with ' ' or '|' \| # followed by a literal '|' (\w+) # followed by a word (the alias)) + \s* # ignore insignificant trailing spaces $/x) { $aliased_columns{$2} = $1; $col = $self->column_alias($1, $2); On Mon, Oct 13, 2014 at 1:17 AM, Bugs in SQL-Abstract-More via RT < bug-SQL-Abstract-More@rt.cpan.org> wrote: Show quoted text
> > Greetings, > > This message has been automatically generated in response to the > creation of a trouble ticket regarding: > "SQL::Abstract::More 1.25 bug", > 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 #99455]. Your ticket is accessible > on the web at: > > https://rt.cpan.org/Ticket/Display.html?id=99455 > > Please include the string: > > [rt.cpan.org #99455] > > 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-More@rt.cpan.org > > ------------------------------------------------------------------------- > Hi SQL::Abstract::More developer. > > I've been using this module for a long time. Recently I updated it from > 1.10 to 1.25 and got my code not working anymore. Let me quote what kind > of changes I had to make to get it working again: > > ) = $sql -> select( -columns => [ 't3.description|switch_descr', > 't1.assigned_by', > - q[ concat_ws( ' ', t2.first_name, > t2.last_name )|assigned_by_long ], > + q[ concat_ws( ' ', t2.first_name, > t2.last_name )|assigned_by_long], > > I think that regexp in newer version got changed and it doesn't account for > a trailing space anymore while looking for a column name alias. As a > result sql statement mentions non-existing column with '|' in its name. > And script dies. > > Hope it's easily fixable, because I widely use this feature and have many > scripts to check and change. > > Let me know if you need any other information. > > With best regards, > Val >
Hi Val, Passing column names surrounded by spaces to the -columns parameter is really an unintended usage; it just happened to work by accident in your case, because probably you don't use the "-want_details" option, but the information stored internally in %aliased_columns was wrong. So this usage would not work for example with DBIx::DataModel. Anyway, fixing the regex as you propose is indeed quite easy; I'm just hesitating because it might break code for some other users who would want to intentionally use initial or trailing spaces in column names (which is possible when using the -quote_char option). This case is mostly theoretical, it seems quite unlikely that anybody would want to do that, but who knows ? Your usage was also unlikely :-) So I need to think a little bit about it before implementing any change. Cheers, Laurent Dami
Subject: Re: [rt.cpan.org #99455] SQL::Abstract::More 1.25 bug
Date: Tue, 14 Oct 2014 09:55:41 -0400
To: bug-SQL-Abstract-More [...] rt.cpan.org
From: val <valkoles [...] gmail.com>
Hi Laurent, You're right about me not using "-want_details" option. I thought about column names/aliases with spaces and decided that you intentionally left out their support: old version used join to figure out column name (spaces were ignored) and its alias and new version describes alias as (\w+) # followed by a word (the alias)). Which already prohibits spaces in aliases. I'm using SQL::Abstract::More with MySQL/MariaDB and thought that if you wanted to support spaces in aliases, you'd mention it in the documentation and probably would go with something like (\w+|'([^']+)') # followed by a word or few words surrounded by quotes (the alias) my $alias = defined $3? $3 : $2; $aliased_columns{ $alias } = $1; $col = $self->column_alias( $1, $alias ); The same can be done for column names too, imho. Might be something to consider actually. Val
On Mon Oct 13 16:07:57 2014, valkoles@gmail.com wrote: Show quoted text
> Here is one way to fix it: > [...]
OK, I applied this patch. Shipped as v1.26