Revision 8f07fac1
Von Bernd Bleßmann vor fast 4 Jahren hinzugefügt
SL/DB/ShopOrder.pm | ||
---|---|---|
122 | 122 |
my $zipcode = $self->billing_street ne '' ? $self->billing_zipcode : ''; |
123 | 123 |
my $email = $self->billing_street ne '' ? $self->billing_email : ''; |
124 | 124 |
|
125 |
if($self->check_trgm) {
|
|
125 |
if(check_trgm($::form->get_standard_dbh())) {
|
|
126 | 126 |
# Fuzzysearch for street to find e.g. "Dorfstrasse - Dorfstr. - Dorfstraße" |
127 | 127 |
my $fs_query = <<SQL; |
128 | 128 |
SELECT * |
... | ... | |
235 | 235 |
return $result || ($self->id <=> $other->id); |
236 | 236 |
} |
237 | 237 |
|
238 |
sub check_trgm { |
|
239 |
my ( $self ) = @_; |
|
240 |
|
|
241 |
my $dbh = $::form->get_standard_dbh(); |
|
242 |
my $sql = "SELECT installed_version FROM pg_available_extensions WHERE name = 'pg_trgm'"; |
|
243 |
my @version = selectall_hashref_query($::form, $dbh, $sql); |
|
244 |
|
|
245 |
return 1 if($version[0]->{installed_version}); |
|
246 |
return 0; |
|
247 |
} |
|
248 |
|
|
249 | 238 |
sub has_differing_delivery_address { |
250 | 239 |
my ($self) = @_; |
251 | 240 |
($self->billing_firstname // '') ne ($self->delivery_firstname // '') || |
... | ... | |
294 | 283 |
|
295 | 284 |
=item C<compare_to> |
296 | 285 |
|
297 |
=item C<check_trgm> |
|
298 |
|
|
299 |
Checks if the postgresextension pg_trgm is installed and return 0 or 1. |
|
300 |
|
|
301 | 286 |
=back |
302 | 287 |
|
303 | 288 |
=head1 TODO |
SL/DBUtils.pm | ||
---|---|---|
13 | 13 |
selectall_ids |
14 | 14 |
prepare_execute_query prepare_query |
15 | 15 |
create_sort_spec does_table_exist |
16 |
add_token); |
|
16 |
add_token check_trgm);
|
|
17 | 17 |
|
18 | 18 |
use strict; |
19 | 19 |
|
... | ... | |
398 | 398 |
return $is_superuser; |
399 | 399 |
} |
400 | 400 |
|
401 |
sub check_trgm { |
|
402 |
my ($dbh) = @_; |
|
403 |
|
|
404 |
my $version = $dbh->selectrow_array(qq|SELECT installed_version FROM pg_available_extensions WHERE name = 'pg_trgm'|); |
|
405 |
|
|
406 |
return !!$version; |
|
407 |
} |
|
408 |
|
|
401 | 409 |
1; |
402 | 410 |
|
403 | 411 |
|
... | ... | |
684 | 692 |
report). If it is undefined then the 'default_dir' parameter will be |
685 | 693 |
used instead. |
686 | 694 |
|
695 |
=item check_trgm |
|
696 |
|
|
697 |
Checks if the postgresextension pg_trgm is installed and return trueish |
|
698 |
or falsish. |
|
699 |
|
|
687 | 700 |
=back |
688 | 701 |
|
689 | 702 |
=head1 DEBUG FUNCTIONS |
t/shop/shop_order.t | ||
---|---|---|
5 | 5 |
use Support::TestSetup; |
6 | 6 |
use Carp; |
7 | 7 |
use Test::Exception; |
8 |
use SL::DBUtils qw(check_trgm); |
|
8 | 9 |
use SL::Dev::ALL; |
9 | 10 |
use SL::Dev::Part qw(new_part); |
10 | 11 |
use SL::Dev::Shop qw(new_shop new_shop_part new_shop_order); |
... | ... | |
71 | 72 |
|
72 | 73 |
reset_state(); |
73 | 74 |
|
74 |
my $trgm = SL::DB::ShopOrder->check_trgm;
|
|
75 |
my $trgm = check_trgm($::form->get_standard_dbh());
|
|
75 | 76 |
|
76 | 77 |
my $shop_trans_id = 1; |
77 | 78 |
|
Auch abrufbar als: Unified diff
DBUtils: Prüfung auf Trigram-Erweiterung aus S/D/ShopOrder in DBUtils verschoben