[Rt-commit] rt branch 5.0/sqlite-function-and-bind created. rt-5.0.3-236-g284c40255b
BPS Git Server
git at git.bestpractical.com
Wed Feb 1 20:21:27 UTC 2023
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, 5.0/sqlite-function-and-bind has been created
at 284c40255bdddac1ab0f311c887573ca26892596 (commit)
- Log -----------------------------------------------------------------
commit 284c40255bdddac1ab0f311c887573ca26892596
Author: sunnavy <sunnavy at bestpractical.com>
Date: Thu Feb 2 04:14:22 2023 +0800
Test attachments shredder
This is initially to test "LENGTH(Content) > ?" for SQLite.
diff --git a/t/shredder/03plugin_attachments.t b/t/shredder/03plugin_attachments.t
new file mode 100644
index 0000000000..bc8c3c2966
--- /dev/null
+++ b/t/shredder/03plugin_attachments.t
@@ -0,0 +1,58 @@
+use strict;
+use warnings;
+
+use Test::Deep;
+use RT::Test::Shredder tests => undef;
+use MIME::Entity;
+
+my $test = "RT::Test::Shredder";
+
+my @ARGS = sort qw(limit files_only file longer);
+
+use_ok('RT::Shredder::Plugin::Attachments');
+{
+ my $plugin = RT::Shredder::Plugin::Attachments->new;
+ isa_ok( $plugin, 'RT::Shredder::Plugin::Attachments' );
+
+ is( lc $plugin->Type, 'search', 'correct type' );
+
+ my @args = sort $plugin->SupportArgs;
+ cmp_deeply( \@args, \@ARGS, "support all args" );
+}
+
+{
+ my $ticket = RT::Ticket->new( RT->SystemUser );
+ my $mime = MIME::Entity->build(
+ From => 'test at example.com',
+ Type => 'text/html',
+ Data => ['test attachment'],
+ );
+
+ $mime->attach(
+ Path => 'share/static/images/bpslogo.png',
+ Type => 'image/png',
+ );
+
+ RT::Test->create_ticket( MIMEObj => $mime, Queue => 'General', Subject => 'test attachment' );
+ my $attachments = RT::Attachments->new( RT->SystemUser );
+ $attachments->Limit( FIELD => 'Filename', VALUE => 'bpslogo.png' );
+ is( $attachments->Count, 1, 'created the attachment' );
+
+ my $plugin = RT::Shredder::Plugin::Attachments->new;
+ my ( $status, $msg ) = $plugin->TestArgs( name => 'bpslogo.png', longer => '1k' );
+ ok( $status, "plugin arguments are ok" ) or diag "error: $msg";
+
+ ( $status, my @objects ) = $plugin->Run;
+ ok( $status, "executed plugin successfully" ) or diag "error: @objects";
+ is( scalar @objects, 1, 'found 1 attachment' );
+
+ my $shredder = $test->shredder_new();
+ $shredder->PutObjects( Objects => \@objects );
+ $shredder->WipeoutAll;
+
+ $attachments = RT::Attachments->new( RT->SystemUser );
+ $attachments->Limit( FIELD => 'Filename', VALUE => 'bpslogo.png' );
+ is( $attachments->Count, 0, 'shredded the attachment' );
+}
+
+done_testing;
commit df4389ba698a101dfc68e2fab68955183bb1463c
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed Feb 1 19:12:12 2023 +0800
Do not quote bind numbers for SQLite
DBD::SQLite assumes that all the bind values are text, which makes the
result of SQL like the following one quite confusing:
SELECT id FROM Attachments WHERE LENGTH(Content) > ?
No matter how small the passed number is, the query will never return
any records.
Since 1.32_02, DBD::SQLite supports sqlite_see_if_its_a_number flag
which can fix this: when it's true, bind numbers won't be quoted.
diff --git a/etc/cpanfile b/etc/cpanfile
index f058f66d87..7dfa715890 100644
--- a/etc/cpanfile
+++ b/etc/cpanfile
@@ -171,7 +171,7 @@ feature 'pg' => sub {
};
feature 'sqlite' => sub {
- requires 'DBD::SQLite', '>= 1.00';
+ requires 'DBD::SQLite', '>= 1.33';
};
diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index 5b63911441..b486b9bbe9 100644
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -149,6 +149,9 @@ sub Connect {
$self->dbh->do( "SET statement_timeout = " . int( $timeout * 1000 ) )
if defined $timeout && length $timeout;
}
+ elsif ( $db_type eq 'SQLite' ) {
+ $self->dbh->{sqlite_see_if_its_a_number} = 1;
+ }
$self->dbh->{'LongReadLen'} = RT->Config->Get('MaxAttachmentSize');
}
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list