Skip to content

Commit

Permalink
Fix PgHstore. Release 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
guimard committed Feb 8, 2019
1 parent 14a649f commit 1e72594
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Build.PL
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Module::Build->new(
requires => { 'Apache::Session' => 0, 'JSON' => 0, },
recommends => { 'DBI' => 0, 'Net::LDAP' => 0.38, },
test_requires => { DBI => 0, 'DBD::SQLite' => 0, },
dist_version => '1.2.9',
dist_version => '1.3.0',
autosplit => [qw(lib/Apache/Session/Browseable/_common.pm)],
configure_requires => { 'Module::Build' => 0, },
)->create_build_script;
5 changes: 4 additions & 1 deletion Changes
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,7 @@ Revision history for Perl extension Apache::Session::Browseable.

1.2.9
- Use either Redis::Fast or Redis
- Fix error when searchOn is used without fields
- Fix error when searchOn is used without fields (PgJSON)

1.3.0
- Fix also PgHstore error when searchOn is used without fields
2 changes: 1 addition & 1 deletion META.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,6 @@
"http://dev.perl.org/licenses/"
]
},
"version" : "v1.2.9",
"version" : "v1.3.0",
"x_serialization_backend" : "JSON::PP version 2.97001"
}
2 changes: 1 addition & 1 deletion META.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,5 @@ requires:
JSON: '0'
resources:
license: http://dev.perl.org/licenses/
version: v1.2.9
version: v1.3.0
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
26 changes: 17 additions & 9 deletions lib/Apache/Session/Browseable/PgHstore.pm
Original file line number Diff line number Diff line change
Expand Up @@ -45,31 +45,39 @@ sub searchOnExpr {
sub _query {
my ( $class, $args, $query, @fields ) = @_;
my %res = ();
my $index =
ref( $args->{Index} )
? $args->{Index}
: [ split /\s+/, $args->{Index} ];

my $dbh = $class->_classDbh($args);
my $table_name = $args->{TableName}
|| $Apache::Session::Store::DBI::TableName;

my $sth;
my $fields =
join( ',', 'id', map { s/'//g; "a_session -> '$_' AS $_" } @fields );
@fields
? join( ',', 'id', map { s/'//g; "a_session -> '$_' AS $_" } @fields )
: '*';
$sth =
$dbh->prepare("SELECT $fields from $table_name where $query->{query}");
$sth->execute( @{ $query->{values} } );

# In this case, PostgreSQL change field name in lowercase
my $res = $sth->fetchall_hashref('id') or return {};
foreach (@fields) {
if ( $_ ne lc($_) ) {
foreach my $s ( keys %$res ) {
$res->{$s}->{$_} = delete $res->{$s}->{ lc $_ };
if (@fields) {
foreach (@fields) {
if ( $_ ne lc($_) ) {
foreach my $s ( keys %$res ) {
$res->{$s}->{$_} = delete $res->{$s}->{ lc $_ };
}
}
}
}
else {
my $self = eval "&${class}::populate();";
my $sub = $self->{unserialize};
foreach my $s ( keys %$res ) {
my $tmp = &$sub( { serialized => $res->{$s}->{a_session} } );
$res->{$s} = $tmp;
}
}
return $res;
}

Expand Down
2 changes: 1 addition & 1 deletion rpm/Apache-Session-Browseable.spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#==============================================================================

%define real_name Apache-Session-Browseable
%define real_version 1.2.9
%define real_version 1.3.0

#==============================================================================
# Main package
Expand Down

0 comments on commit 1e72594

Please sign in to comment.