Skip Menu |

This queue is for tickets about the perl-ldap CPAN distribution.

Report information
The Basics
Id: 87945
Status: rejected
Priority: 0/
Queue: perl-ldap

People
Owner: Nobody in particular
Requestors: bugs [...] innuce.ch
Cc:
AdminCc:

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



Subject: Enhancement for Net::LDAP::Search
Date: Mon, 19 Aug 2013 16:29:41 +0200
To: bug-perl-ldap [...] rt.cpan.org
From: Stefan <bugs [...] innuce.ch>
Hi there I modified sorted() so you can sort ascending and descending. Maybe you can merge it into trunk (i should not break the original function): you can activate descending sorts over $result->sortorder(1); --snip-- sub sortorder { my $self = shift; my $order = shift; if ($order == 1){ $self->{sortorder}=1; } else { $self->{sortorder}=0; } } sub sorted { my $self = shift; $self->sync unless exists $self->{resultCode}; $self->{sortorder} = 0 if (!$self->{sortorder}; return unless exists $self->{entries} && ref($self->{entries}); return @{$self->{entries}} unless @{$self->{entries}} > 1; require Net::LDAP::Util; if ($self->{sortorder} == 0){ map { $_->[0] } sort { my $v; my $i = 2; foreach my $attr (@_) { $v = ($a->[$i] ||= join("\000", @{$a->[0]->get_value($attr, asref => 1) || []})) cmp ($b->[$i] ||= join("\000", @{$b->[0]->get_value($attr, asref => 1) || []})) and last; $i++; } $v ||= ($a->[1] ||= Net::LDAP::Util::canonical_dn( $a->[0]->dn, "reverse" => 1, separator => "\0")) cmp ($b->[1] ||= Net::LDAP::Util::canonical_dn( $b->[0]->dn, "reverse" => 1, separator => "\0")); } map { [ $_ ] } @{$self->{entries}}; } else { map { $_->[0] } sort { my $v; my $i = 2; foreach my $attr (@_) { $v = ($b->[$i] ||= join("\000", @{$b->[0]->get_value($attr, asref => 1) || []})) cmp ($a->[$i] ||= join("\000", @{$a->[0]->get_value($attr, asref => 1) || []})) and last; $i++; } $v ||= ($a->[1] ||= Net::LDAP::Util::canonical_dn( $a->[0]->dn, "reverse" => 1, separator => "\0")) cmp ($b->[1] ||= Net::LDAP::Util::canonical_dn( $b->[0]->dn, "reverse" => 1, separator => "\0")); } map { [ $_ ] } @{$self->{entries}}; } } -- snip Cheers Stefan
Hi Stefan, On Mon Aug 19 10:30:05 2013, bugs@innuce.ch wrote: Show quoted text
> I modified sorted() so you can sort ascending and descending. Maybe > you can merge it into trunk (i should not break the original function): > > you can activate descending sorts over > > $result->sortorder(1);
sorry that it took so long to answer. But I do not intend to use this patch. It solves nothing that cannot be achied with existing means of Net::LDAP::Search. If you - after using the existing sorted() method - use e.g. pop_entry() to retrieve the entries from the Search object instead of shift_entry(), then the result is the sameas the one of your patch. My answer might be different if your patch would allow for mixed sorting i.e. upward for the first attribute, downward for the second [in case the first one compares to equality], ... Ideally this should be possible without a separate function.
Subject: Re: [rt.cpan.org #87945] Enhancement for Net::LDAP::Search
Date: Mon, 17 Mar 2014 12:40:57 +0100
To: bug-perl-ldap [...] rt.cpan.org
From: Stefan <bugs [...] innuce.ch>
Hi Peter, Seems reasonable. Maybe you can mention this in the docs, so guys like me get the trick :-) Stefan On 08.03.2014 14:55, Peter Marschall via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=87945 > > > Hi Stefan, > > On Mon Aug 19 10:30:05 2013, bugs@innuce.ch wrote:
>> I modified sorted() so you can sort ascending and descending. Maybe >> you can merge it into trunk (i should not break the original function): >> >> you can activate descending sorts over >> >> $result->sortorder(1);
> sorry that it took so long to answer. > > But I do not intend to use this patch. > It solves nothing that cannot be achied with existing means of Net::LDAP::Search. > > If you - after using the existing sorted() method - use e.g. pop_entry() to retrieve the entries from the Search object instead of shift_entry(), then the result is the sameas the one of your patch. > > My answer might be different if your patch would allow for mixed sorting > i.e. upward for the first attribute, downward for the second [in case the first one compares to equality], ... > Ideally this should be possible without a separate function. >
Hi Stefan, On Mon Mar 17 07:41:20 2014, bugs@innuce.ch wrote: Show quoted text
> Seems reasonable. Maybe you can mention this in the docs, so guys like me get the trick :-)
Feel free to send in a patch with a new FAQ entry [I haven't checked this specific question is already there ;-]. Your mail domain & your name make me assume you speak German too: Eigentlich hab ich ja gehofft, Du nimmst die Herausforderung an, sorted() so umzubauen, dass es "gemischt" (d.h. z.B. erstes Attribut vorwärts, zweites rückwärts, ..) sortieren kann.. Meine Idee, das ohne Helfer-Funktion hinzukriegen, geht in Richtung "-" als Präfix für ein Attribut, das rückwärts sortiert werden soll. also z.B. @sorted = $search->sorted(qw/-sn givenname/); Das sollte dann rückwärts nach Nachnamen sortieren, und bei Gleichheit vorwärts nach Vornamen. Da Attributnamen gemäß RFC nicht mit "-" beginnen dürfen wäre das eine sichere & elegante, natürliche Erweiterung. Wie wär's? Grüße Peter