Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
best-practical
rt
Commits
55c6d2a2
Commit
55c6d2a2
authored
Jun 13, 2014
by
Alex Vandiver
Browse files
Merge branch '4.2/cf-is-null-warnings' into 4.2-trunk
parents
cb162847
f9a0394f
Changes
3
Hide whitespace changes
Inline
Side-by-side
lib/RT/SearchBuilder.pm
View file @
55c6d2a2
...
...
@@ -518,6 +518,31 @@ sub _LimitCustomField {
return
%args
;
};
# Special Limit (we can exit early)
# IS NULL and IS NOT NULL checks
if
(
$op
=~
/^IS( NOT)?$/i
)
{
my
(
$ocfvalias
,
$CFs
)
=
$self
->
_CustomFieldJoin
(
$cfkey
,
$cf
,
$ltype
);
$self
->
_OpenParen
(
$args
{
SUBCLAUSE
}
);
$self
->
Limit
(
%args
,
ALIAS
=>
$ocfvalias
,
FIELD
=>
(
$column
||
'
id
'),
OPERATOR
=>
$op
,
VALUE
=>
$value
,
);
# See below for an explanation of this limit
$self
->
Limit
(
ALIAS
=>
$CFs
,
FIELD
=>
'
Name
',
OPERATOR
=>
'
IS NOT
',
VALUE
=>
'
NULL
',
ENTRYAGGREGATOR
=>
'
AND
',
SUBCLAUSE
=>
$args
{
SUBCLAUSE
},
)
if
$CFs
;
$self
->
_CloseParen
(
$args
{
SUBCLAUSE
}
);
return
;
}
########## Content pre-parsing if we know things about the CF
if
(
blessed
(
$cf
)
and
delete
$args
{
PREPARSE
}
)
{
my
$type
=
$cf
->
Type
;
...
...
@@ -652,29 +677,6 @@ sub _LimitCustomField {
}
########## Limits
# IS NULL and IS NOT NULL checks
if
(
$op
=~
/^IS( NOT)?$/i
)
{
my
(
$ocfvalias
,
$CFs
)
=
$self
->
_CustomFieldJoin
(
$cfkey
,
$cf
,
$ltype
);
$self
->
_OpenParen
(
$args
{
SUBCLAUSE
}
);
$self
->
Limit
(
%args
,
ALIAS
=>
$ocfvalias
,
FIELD
=>
(
$column
||
'
id
'),
OPERATOR
=>
$op
,
VALUE
=>
$value
,
);
# See below for an explanation of this limit
$self
->
Limit
(
ALIAS
=>
$CFs
,
FIELD
=>
'
Name
',
OPERATOR
=>
'
IS NOT
',
VALUE
=>
'
NULL
',
ENTRYAGGREGATOR
=>
'
AND
',
SUBCLAUSE
=>
$args
{
SUBCLAUSE
},
)
if
$CFs
;
$self
->
_CloseParen
(
$args
{
SUBCLAUSE
}
);
return
;
}
my
$single_value
=
!
blessed
(
$cf
)
||
$cf
->
SingleValue
;
my
$negative_op
=
(
$op
eq
'
!=
'
||
$op
=~
/\bNOT\b/i
);
...
...
t/customfields/date_search.t
View file @
55c6d2a2
...
...
@@ -3,7 +3,7 @@ use Test::MockTime qw(set_fixed_time restore_time);
use
warnings
;
use
strict
;
use
RT::
Test
nodata
=>
1
,
tests
=>
21
;
use
RT::
Test
nodata
=>
1
,
tests
=>
undef
;
RT::
Test
->
set_rights
(
{
Principal
=>
'
Everyone
',
Right
=>
[
qw(
...
...
@@ -134,6 +134,28 @@ is( $ticket->CustomFieldValues->First->Content, '2010-05-04', 'date in db is' );
is
(
$tickets
->
Count
,
0
,
'
did not find the ticket with > 2010-05-05
'
);
}
{
my
$tickets
=
RT::
Tickets
->
new
(
RT
->
SystemUser
);
$tickets
->
LimitCustomField
(
CUSTOMFIELD
=>
$cf
->
id
,
OPERATOR
=>
'
IS
',
VALUE
=>
'
NULL
',
);
is
(
$tickets
->
Count
,
0
,
'
did not find the ticket with date IS NULL
'
);
}
{
my
$tickets
=
RT::
Tickets
->
new
(
RT
->
SystemUser
);
$tickets
->
LimitCustomField
(
CUSTOMFIELD
=>
$cf
->
id
,
OPERATOR
=>
'
IS NOT
',
VALUE
=>
'
NULL
',
);
is
(
$tickets
->
Count
,
1
,
'
did find the ticket with date IS NOT NULL
'
);
}
# relative search by users in different TZs
{
my
$ticket
=
RT::
Ticket
->
new
(
RT
->
SystemUser
);
...
...
@@ -164,3 +186,4 @@ is( $ticket->CustomFieldValues->First->Content, '2010-05-04', 'date in db is' );
is
(
$tickets
->
Count
,
1
,
'
found the tickets
'
);
}
done_testing
;
t/customfields/datetime_search.t
View file @
55c6d2a2
...
...
@@ -3,7 +3,7 @@ use Test::MockTime qw(set_fixed_time restore_time);
use
warnings
;
use
strict
;
use
RT::
Test
nodata
=>
1
,
tests
=>
30
;
use
RT::
Test
nodata
=>
1
,
tests
=>
undef
;
RT
->
Config
->
Set
(
'
Timezone
'
=>
'
EST5EDT
'
);
# -04:00
RT::
Test
->
set_rights
(
...
...
@@ -206,6 +206,29 @@ while( my $ticket = $tickets->Next ) {
is
(
$tickets
->
Count
,
0
);
}
{
my
$tickets
=
RT::
Tickets
->
new
(
RT
->
SystemUser
);
$tickets
->
LimitCustomField
(
CUSTOMFIELD
=>
$cf
->
id
,
OPERATOR
=>
'
IS
',
VALUE
=>
'
NULL
',
);
is
(
$tickets
->
Count
,
0
,
'
did not find the ticket with date IS NULL
'
);
}
{
my
$tickets
=
RT::
Tickets
->
new
(
RT
->
SystemUser
);
$tickets
->
LimitCustomField
(
CUSTOMFIELD
=>
$cf
->
id
,
OPERATOR
=>
'
IS NOT
',
VALUE
=>
'
NULL
',
);
is
(
$tickets
->
Count
,
2
,
'
did find the ticket with date IS NOT NULL
'
);
}
# search by relative date with '=', but date only
{
my
$ticket
=
RT::
Ticket
->
new
(
RT
->
SystemUser
);
...
...
@@ -237,3 +260,4 @@ while( my $ticket = $tickets->Next ) {
is
(
$tickets
->
Count
,
0
);
}
done_testing
;
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment