my $zipcode = $self->billing_street ne '' ? $self->billing_zipcode : '';
my $email = $self->billing_street ne '' ? $self->billing_email : '';
- if($self->check_trgm) {
+ if(check_trgm($::form->get_standard_dbh())) {
# Fuzzysearch for street to find e.g. "Dorfstrasse - Dorfstr. - Dorfstraße"
my $fs_query = <<SQL;
SELECT *
return $result || ($self->id <=> $other->id);
}
-sub check_trgm {
- my ( $self ) = @_;
-
- my $dbh = $::form->get_standard_dbh();
- my $sql = "SELECT installed_version FROM pg_available_extensions WHERE name = 'pg_trgm'";
- my @version = selectall_hashref_query($::form, $dbh, $sql);
-
- return 1 if($version[0]->{installed_version});
- return 0;
-}
-
sub has_differing_delivery_address {
my ($self) = @_;
($self->billing_firstname // '') ne ($self->delivery_firstname // '') ||
=item C<compare_to>
-=item C<check_trgm>
-
-Checks if the postgresextension pg_trgm is installed and return 0 or 1.
-
=back
=head1 TODO
selectall_ids
prepare_execute_query prepare_query
create_sort_spec does_table_exist
- add_token);
+ add_token check_trgm);
use strict;
return $is_superuser;
}
+sub check_trgm {
+ my ($dbh) = @_;
+
+ my $version = $dbh->selectrow_array(qq|SELECT installed_version FROM pg_available_extensions WHERE name = 'pg_trgm'|);
+
+ return !!$version;
+}
+
1;
report). If it is undefined then the 'default_dir' parameter will be
used instead.
+=item check_trgm
+
+Checks if the postgresextension pg_trgm is installed and return trueish
+or falsish.
+
=back
=head1 DEBUG FUNCTIONS
use Support::TestSetup;
use Carp;
use Test::Exception;
+use SL::DBUtils qw(check_trgm);
use SL::Dev::ALL;
use SL::Dev::Part qw(new_part);
use SL::Dev::Shop qw(new_shop new_shop_part new_shop_order);
reset_state();
-my $trgm = SL::DB::ShopOrder->check_trgm;
+my $trgm = check_trgm($::form->get_standard_dbh());
my $shop_trans_id = 1;