[Rt-commit] rt branch, master, updated. rt-4.1.6-111-g9b757f0
Thomas Sibley
trs at bestpractical.com
Fri Jan 18 20:05:23 EST 2013
The branch, master has been updated
via 9b757f0015614000c71a29eaa2387d141772913e (commit)
via c64e974f6c1f8eea3c17c4621935b22a3f4ae0e3 (commit)
via e29fc5fb72befb09b5d52bd8a749437d3ceae6b1 (commit)
via f9adf73b0c93d58bb04c5646bf03011dbffb68e4 (commit)
via 4f61730bb99b607c81bf52ab160762c138fbd070 (commit)
via 912339206a5727bc196f096f1d92e759d1c4dd64 (commit)
via c6be454efe6d107ad5a995839bf95caced0f1e73 (commit)
via 2fed54ab9b7aae1bb2708265ae32633aceda7e52 (commit)
via 43710e2a531de08952d70162c9373c53c242dae2 (commit)
from eccf3f7afd51483883f48cee3462f6e4fe5a5b99 (commit)
Summary of changes:
lib/RT/Links.pm | 1 -
lib/RT/Report/Tickets.pm | 1 -
lib/RT/Role/SearchBuilder/Roles.pm | 2 +-
lib/RT/Tickets.pm | 432 ++++++++++++++++++++++---------------
lib/RT/Tickets_SQL.pm | 354 ------------------------------
share/html/Search/Build.html | 2 +-
6 files changed, 255 insertions(+), 537 deletions(-)
delete mode 100644 lib/RT/Tickets_SQL.pm
- Log -----------------------------------------------------------------
commit 9b757f0015614000c71a29eaa2387d141772913e
Merge: eccf3f7 c64e974
Author: Thomas Sibley <trs at bestpractical.com>
Date: Fri Jan 18 16:55:55 2013 -0800
Merge branch '4.2/tickets-cleanup'
Conflicts:
lib/RT/Tickets_SQL.pm
507e226 (from 4.0-trunk) changed %lcfields to %LOWER_CASE_FIELDS.
Port that commit to lib/RT/Tickets.pm like the rest of Tickets_SQL.pm.
diff --cc lib/RT/Tickets.pm
index 075554b,69244b2..4257cee
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@@ -372,9 -363,9 +366,9 @@@ sub _EnumLimit
my $class = "RT::" . $meta->[1];
my $o = $class->new( $sb->CurrentUser );
$o->Load($value);
- $value = $o->Id;
+ $value = $o->Id || 0;
}
- $sb->_SQLLimit(
+ $sb->Limit(
FIELD => $field,
VALUE => $value,
OPERATOR => $op,
@@@ -3345,6 -3301,124 +3304,121 @@@ BUG: There should be an API for thi
=cut
+ =head2 FromSQL
+
+ Convert a RT-SQL string into a set of SearchBuilder restrictions.
+
+ Returns (1, 'Status message') on success and (0, 'Error Message') on
+ failure.
+
+ =cut
+
+ sub _parser {
+ my ($self,$string) = @_;
+ my $ea = '';
+
- # Lower Case version of %FIELD_METADATA, for case insensitivity
- my %lcfields = map { ( lc($_) => $_ ) } (keys %FIELD_METADATA);
-
+ my %callback;
+ $callback{'OpenParen'} = sub {
+ $self->_OpenParen
+ };
+ $callback{'CloseParen'} = sub {
+ $self->_CloseParen;
+ };
+ $callback{'EntryAggregator'} = sub { $ea = $_[0] || '' };
+ $callback{'Condition'} = sub {
+ my ($key, $op, $value) = @_;
+
+ # key has dot then it's compound variant and we have subkey
+ my $subkey = '';
+ ($key, $subkey) = ($1, $2) if $key =~ /^([^\.]+)\.(.+)$/;
+
+ # normalize key and get class (type)
+ my $class;
- if (exists $lcfields{lc $key}) {
- $key = $lcfields{lc $key};
++ if (exists $LOWER_CASE_FIELDS{lc $key}) {
++ $key = $LOWER_CASE_FIELDS{lc $key};
+ $class = $FIELD_METADATA{$key}->[0];
+ }
+ die "Unknown field '$key' in '$string'" unless $class;
+
+ # replace __CurrentUser__ with id
+ $value = $self->CurrentUser->id if $value eq '__CurrentUser__';
+
+
+ unless( $dispatch{ $class } ) {
+ die "No dispatch method for class '$class'"
+ }
+ my $sub = $dispatch{ $class };
+
+ $sub->( $self, $key, $op, $value,
+ ENTRYAGGREGATOR => $ea,
+ SUBKEY => $subkey,
+ );
+ $ea = '';
+ };
+ RT::SQL::Parse($string, \%callback);
+ }
+
+ sub FromSQL {
+ my ($self,$query) = @_;
+
+ {
+ # preserve first_row and show_rows across the CleanSlate
+ local ($self->{'first_row'}, $self->{'show_rows'}, $self->{_sql_looking_at});
+ $self->CleanSlate;
+ $self->_InitSQL();
+ }
+
+ return (1, $self->loc("No Query")) unless $query;
+
+ $self->{_sql_query} = $query;
+ eval {
+ local $self->{parsing_ticketsql} = 1;
+ $self->_parser( $query );
+ };
+ if ( $@ ) {
+ $RT::Logger->error( $@ );
+ return (0, $@);
+ }
+
+ # We only want to look at EffectiveId's (mostly) for these searches.
+ unless ( $self->{_sql_looking_at}{effectiveid} ) {
+ $self->Limit(
+ FIELD => 'EffectiveId',
+ VALUE => 'main.id',
+ ENTRYAGGREGATOR => 'AND',
+ QUOTEVALUE => 0,
+ );
+ }
+ unless ( $self->{_sql_looking_at}{type} ) {
+ $self->Limit( FIELD => 'Type', VALUE => 'ticket' );
+ }
+
+ # We don't want deleted tickets unless 'allow_deleted_search' is set
+ unless( $self->{'allow_deleted_search'} ) {
+ $self->Limit(
+ FIELD => 'Status',
+ OPERATOR => '!=',
+ VALUE => 'deleted',
+ );
+ }
+
+ # set SB's dirty flag
+ $self->{'must_redo_search'} = 1;
+ $self->{'RecalcTicketLimits'} = 0;
+
+ return (1, $self->loc("Valid Query"));
+ }
+
+ =head2 Query
+
+ Returns the last string passed to L</FromSQL>.
+
+ =cut
+
+ sub Query {
+ my $self = shift;
+ return $self->{_sql_query};
+ }
=head2 NewItem
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list