diff --git a/lib/DBD/SQLite.pm b/lib/DBD/SQLite.pm index abc8064..5c29d90 100644 --- a/lib/DBD/SQLite.pm +++ b/lib/DBD/SQLite.pm @@ -1723,10 +1723,10 @@ at runtime; however, since FTS3 was never advertised in versions prior to 1.31, the change should be invisible to the vast majority of C users. If, however, there are any applications that nevertheless were built using the "Standard Query" syntax, -they have to be migrated; but the conversion -function provided in in L -is there to help. - +they have to be migrated, because the precedence of the C operator +has changed. Conversion from old to new syntax can be +automated through L, published +in a separate distribution. =head2 Tokenizers diff --git a/lib/DBD/SQLite/FTS3Transitional.pm b/lib/DBD/SQLite/FTS3Transitional.pm deleted file mode 100644 index ae19a39..0000000 --- a/lib/DBD/SQLite/FTS3Transitional.pm +++ /dev/null @@ -1,99 +0,0 @@ -package DBD::SQLite::FTS3Transitional; - -use 5.006; -use strict; -use warnings; -no warnings 'uninitialized'; -use Exporter (); - -our $VERSION = '1.30_06'; -our @ISA = 'Exporter'; -our @EXPORT_OK = qw/fts3_convert/; - -sub fts3_convert { - my $in = shift; - my $out = ""; - - # decompose input string into tokens - my @tokens = $in =~ / - # minus sign - | \bOR\b # OR keyword - | ".*?" # phrase query - | \S+ # term - /xg; - - # build the output string - while (@tokens) { - - # -a => (NOT a) - if ($tokens[0] eq '-') { - my (undef, $right) = splice(@tokens, 0, 2); - $out .= " (NOT $right)"; - } - - # a OR b => (a OR b) - elsif (@tokens >= 2 && $tokens[1] eq 'OR') { - my ($left, undef, $right) = splice(@tokens, 0, 3); - if ($right eq '-') { - $right = "NOT " . shift @tokens; - } - $out .= " ($left OR $right)"; - } - - # plain term - else { - $out .= " " . shift @tokens; - } - } - - return $out; -} - - -1; - -__END__ - -=head1 NAME - -DBD::SQLite::FTS3Transitional - helper function for migrating FTS3 applications - -=head1 SYNOPSIS - - use DBD::SQLite::FTS3Transitional qw/fts3_convert/; - my $new_match_syntax = fts3_convert($old_match_syntax); - my $sql = "SELECT ... FROM ... WHERE col MATCH $new_match_syntax"; - -=head1 DESCRIPTION - -Starting from version 1.31, C uses the new, recommended -"Enhanced Query Syntax" for binary set operators in fulltext FTS3 queries -(AND, OR, NOT, possibly nested with parenthesis). - -Previous versions of C used the -"Standard Query Syntax" (see L). - -This module helps converting SQLite application built with the old, -"Standard" query syntax, to the new "Extended" syntax. - -=head1 FUNCTIONS - -=head2 fts3_convert - -Takes as input a string for the MATCH clause in a FTS3 fulltext search; -returns the same clause rewritten in new, "Extended" syntax. - -=head1 AUTHOR - -Laurent Dami Edami@cpan.orgE - -=head1 COPYRIGHT - -Copyright 2010 Laurent Dami. - -This program is free software; you can redistribute -it and/or modify it under the same terms as Perl itself. - -The full text of the license can be found in the -LICENSE file included with this module. - -=cut diff --git a/t/44_fts3_transitional.t b/t/44_fts3_transitional.t deleted file mode 100644 index 25eae45..0000000 --- a/t/44_fts3_transitional.t +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/perl - -use strict; -BEGIN { - $| = 1; - $^W = 1; -} - -use t::lib::Test; -use Test::More; -use Test::NoWarnings; - -my @tests = ( - ['foo bar' => 'foo bar' ], - ['foo -bar' => 'foo (NOT bar)' ], - ['foo* -bar*' => 'foo* (NOT bar*)' ], - ['foo bar OR bie buz' => 'foo (bar OR bie) buz' ], - ['-foo bar OR -bie buz' => '(NOT foo) (bar OR NOT bie) buz'], - ['"kyrie eleison" OR "christe eleison"' - => '("kyrie eleison" OR "christe eleison")'], - ); - - -plan tests => 1 + @tests; - -use DBD::SQLite::FTS3Transitional qw/fts3_convert/; - -foreach my $t (@tests) { - my ($old_syntax, $expected_new) = @$t; - my $new = fts3_convert($old_syntax); - $new =~ s/^\s+//; - is($new, $expected_new, $old_syntax); -} - -