diff options
Diffstat (limited to 'databases')
-rw-r--r-- | databases/p5-DBIx-SearchBuilder/Makefile | 1 | ||||
-rw-r--r-- | databases/p5-DBIx-SearchBuilder/files/patch-upstream-1.65_1 | 46 |
2 files changed, 47 insertions, 0 deletions
diff --git a/databases/p5-DBIx-SearchBuilder/Makefile b/databases/p5-DBIx-SearchBuilder/Makefile index 6a1d2042a2a0..5bf5d81597e9 100644 --- a/databases/p5-DBIx-SearchBuilder/Makefile +++ b/databases/p5-DBIx-SearchBuilder/Makefile @@ -3,6 +3,7 @@ PORTNAME= DBIx-SearchBuilder PORTVERSION= 1.65 +PORTREVISION= 1 CATEGORIES= databases perl5 MASTER_SITES= CPAN PKGNAMEPREFIX= p5- diff --git a/databases/p5-DBIx-SearchBuilder/files/patch-upstream-1.65_1 b/databases/p5-DBIx-SearchBuilder/files/patch-upstream-1.65_1 new file mode 100644 index 000000000000..5d1a4a60f4e2 --- /dev/null +++ b/databases/p5-DBIx-SearchBuilder/files/patch-upstream-1.65_1 @@ -0,0 +1,46 @@ +--- lib/DBIx/SearchBuilder/Handle/Pg.pm 2013-07-02 21:12:09.000000000 +0400 ++++ lib/DBIx/SearchBuilder/Handle/Pg.pm 2014-07-08 23:11:22.000000000 +0400 +@@ -235,9 +235,15 @@ sub DistinctQuery { + # It's hard to show with tests. Pg's optimizer can choose execution + # plan not guaranting order + +- # So if we are ordering by something that is not in 'main', the we GROUP +- # BY all columns and adjust the ORDER_BY accordingly +- local $sb->{group_by} = [ map {+{FIELD => $_}} $self->Fields($table) ]; ++ my $groups; ++ if ($self->DatabaseVersion =~ /^(\d+)\.(\d+)/ and ($1 > 9 or ($1 == 9 and $2 >= 1))) { ++ # Pg 9.1 supports "SELECT main.foo ... GROUP BY main.id" if id is the primary key ++ $groups = [ {FIELD => "id"} ]; ++ } else { ++ # For earlier versions, we have to list out all of the columns ++ $groups = [ map {+{FIELD => $_}} $self->Fields($table) ]; ++ } ++ local $sb->{group_by} = $groups; + local $sb->{'order_by'} = [ + map { + ($_->{'ALIAS'}||'') ne "main" +--- lib/DBIx/SearchBuilder/Handle.pm 2013-06-06 23:06:18.000000000 +0400 ++++ lib/DBIx/SearchBuilder/Handle.pm 2014-07-08 23:11:22.000000000 +0400 +@@ -1428,18 +1428,19 @@ sub DistinctCount { + + sub Fields { + my $self = shift; +- my $table = shift; ++ my $table = lc shift; + +- unless ( keys %FIELDS_IN_TABLE ) { +- my $sth = $self->dbh->column_info( undef, '', '%', '%' ) ++ unless ( $FIELDS_IN_TABLE{$table} ) { ++ $FIELDS_IN_TABLE{ $table } = []; ++ my $sth = $self->dbh->column_info( undef, '', $table, '%' ) + or return (); + my $info = $sth->fetchall_arrayref({}); + foreach my $e ( @$info ) { +- push @{ $FIELDS_IN_TABLE{ lc $e->{'TABLE_NAME'} } ||= [] }, lc $e->{'COLUMN_NAME'}; ++ push @{ $FIELDS_IN_TABLE{ $table } }, lc $e->{'COLUMN_NAME'}; + } + } + +- return @{ $FIELDS_IN_TABLE{ lc $table } || [] }; ++ return @{ $FIELDS_IN_TABLE{ $table } }; + } |