Use proper quote handling in _count_subq_rs
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / ResultSet.pm
index 18cc57d..c82711a 100644 (file)
@@ -1730,7 +1730,8 @@ sub _count_subq_rs {
         $sql_maker->{name_sep} = '';
       }
 
-      my ($lquote, $rquote, $sep) = map { quotemeta $_ } ($sql_maker->_quote_chars, $sql_maker->name_sep);
+      my $sep = quotemeta($sql_maker->name_sep);
+      my $ident_re = $sql_maker->_quoted_ident_re;
 
       my $having_sql = $sql_maker->_parse_rs_attrs ({ having => $attrs->{having} });
       my %seen_having;
@@ -1738,13 +1739,13 @@ sub _count_subq_rs {
       # search for both a proper quoted qualified string, for a naive unquoted scalarref
       # and if all fails for an utterly naive quoted scalar-with-function
       while ($having_sql =~ /
-        $rquote $sep $lquote (.+?) $rquote
+        $ident_re $sep ($ident_re)
           |
         [\s,] \w+ \. (\w+) [\s,]
           |
-        [\s,] $lquote (.+?) $rquote [\s,]
+        [\s,] ($ident_re) [\s,]
       /gx) {
-        my $part = $1 || $2 || $3;  # one of them matched if we got here
+        my $part = $sql_maker->_unquote($1 || $2 || $3);  # one of them matched if we got here
         unless ($seen_having{$part}++) {
           push @parts, $part;
         }
@@ -4156,10 +4157,11 @@ names:
 
 B<NOTE:> You will almost always need a corresponding L</as> attribute when you
 use L</select>, to instruct DBIx::Class how to store the result of the column.
-Also note that the L</as> attribute has nothing to do with the SQL-side 'AS'
-identifier aliasing. You can however alias a function, so you can use it in
-e.g. an C<ORDER BY> clause. This is done via the C<-as> B<select function
-attribute> supplied as shown in the example above.
+
+Also note that the L</as> attribute has B<nothing to do> with the SQL-side
+C<AS> identifier aliasing. You B<can> alias a function (so you can use it e.g.
+in an C<ORDER BY> clause), however this is done via the C<-as> B<select
+function attribute> supplied as shown in the example above.
 
 =head2 +select
 
@@ -4189,8 +4191,10 @@ Indicates DBIC-side names for object inflation. That is L</as> indicates the
 slot name in which the column value will be stored within the
 L<Row|DBIx::Class::Row> object. The value will then be accessible via this
 identifier by the C<get_column> method (or via the object accessor B<if one
-with the same name already exists>) as shown below. The L</as> attribute has
-B<nothing to do> with the SQL-side C<AS>. See L</select> for details.
+with the same name already exists>) as shown below.
+
+The L</as> attribute has B<nothing to do> with the SQL-side identifier
+aliasing C<AS>. See L</select> for details.
 
   $rs = $schema->resultset('Employee')->search(undef, {
     select => [