Skip to content

Commit

Permalink
E47: change in SQL::Abstract v2 breaks sqlJoin
Browse files Browse the repository at this point in the history
  • Loading branch information
markov2 committed Feb 23, 2021
1 parent 88ee74d commit be64cb8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ CHANGES from 3.7.4 onwards
=== release 3.7.5 (under construction)
- #361 Individuals without roles not shown in call list
- #365 = E41: correct use of AND between keyword lists
- E47: change in SQL::Abstract v2 breaks sqlJoin
1 change: 1 addition & 0 deletions install/220.perl-modules
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ my @dependencies = qw(
Module::Find 0
Module::Load 0
Pod::Man 0
SQL::Abstract 2.00
SQL::Abstract::More 0
String::Compare::ConstantTime 0
Sys::Syslog 0
Expand Down
19 changes: 8 additions & 11 deletions pm/Taranis/Database.pm
Original file line number Diff line number Diff line change
Expand Up @@ -280,21 +280,18 @@ sub logError {
# FULL JOIN: Return rows when there is a match in one of the tables
sub sqlJoin {
my ( $self, $join_columns, $stmnt ) = @_;
my ( $str, $table_key);
my %columns;
my $str;

for $table_key ( keys %$join_columns ) {
$str .= " " . $table_key . " ON ";
foreach my $table_key ( keys %$join_columns ) {
my $columns = $join_columns->{$table_key};
for my $column_key ( keys %$columns ) {
$str .= $column_key . " = " . $columns->{$column_key};
}
my ($key, $other) = %$columns;
$str .= " $table_key ON $key = $other ";
}

if ( $stmnt =~ m/(WHERE)/ ) {
$stmnt =~ s/( WHERE \()/$str WHERE \(/;
} elsif ( $stmnt =~ m/(ORDER BY)/ ) {
$stmnt =~ s/( ORDER BY )/$str ORDER BY /;
if ( $stmnt =~ m/ WHERE / ) {
$stmnt =~ s/ WHERE /$str WHERE /;
} elsif ( $stmnt =~ m/ ORDER BY / ) {
$stmnt =~ s/ ORDER BY /$str ORDER BY /;
} else {
$stmnt .= $str;
}
Expand Down

0 comments on commit be64cb8

Please sign in to comment.