[Rt-commit] rt branch 5.0/cf-values-empty-category-sort-order created. rt-5.0.4-66-g1018fbc151
BPS Git Server
git at git.bestpractical.com
Fri Jul 14 20:58:46 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/cf-values-empty-category-sort-order has been created
at 1018fbc151967ebc03152f8dbf1b2ac1adb99ad0 (commit)
- Log -----------------------------------------------------------------
commit 1018fbc151967ebc03152f8dbf1b2ac1adb99ad0
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Jul 14 15:26:36 2023 -0400
Convert empty strings to NULL for Category of CustomFieldValues
Both NULL and "" show up as "(no value)" in UI, but they have different
sort order, which is confusing especially considering that Category is
one of the default sort columns now.
This commit converts empty strings to NULL to avoid the inconsistent
order issue. As Oracle doesn't support empty strings, we don't need to
fix its data.
diff --git a/etc/upgrade/5.0.5/schema.Pg b/etc/upgrade/5.0.5/schema.Pg
new file mode 100644
index 0000000000..00eb899f46
--- /dev/null
+++ b/etc/upgrade/5.0.5/schema.Pg
@@ -0,0 +1 @@
+UPDATE CustomFieldValues SET Category=NULL WHERE Category='';
diff --git a/etc/upgrade/5.0.5/schema.SQLite b/etc/upgrade/5.0.5/schema.SQLite
new file mode 100644
index 0000000000..00eb899f46
--- /dev/null
+++ b/etc/upgrade/5.0.5/schema.SQLite
@@ -0,0 +1 @@
+UPDATE CustomFieldValues SET Category=NULL WHERE Category='';
diff --git a/etc/upgrade/5.0.5/schema.mysql b/etc/upgrade/5.0.5/schema.mysql
new file mode 100644
index 0000000000..00eb899f46
--- /dev/null
+++ b/etc/upgrade/5.0.5/schema.mysql
@@ -0,0 +1 @@
+UPDATE CustomFieldValues SET Category=NULL WHERE Category='';
diff --git a/lib/RT/CustomFieldValue.pm b/lib/RT/CustomFieldValue.pm
index 94e5ffeb8e..421a3cb585 100644
--- a/lib/RT/CustomFieldValue.pm
+++ b/lib/RT/CustomFieldValue.pm
@@ -74,7 +74,7 @@ sub Create {
Name => '',
Description => '',
SortOrder => 0,
- Category => '',
+ Category => undef,
@_,
);
@@ -91,7 +91,7 @@ sub Create {
my ($id, $msg) = $self->SUPER::Create(
CustomField => $cf_id,
- map { $_ => $args{$_} } qw(Name Description SortOrder Category)
+ map { $_ => $args{$_} } grep { defined $args{$_} and length $args{$_} } qw(Name Description SortOrder Category)
);
return ($id, $msg);
}
@@ -267,6 +267,12 @@ Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
=cut
+sub SetCategory {
+ my $self = shift;
+ my $value = shift;
+ undef $value unless defined $value && length $value;
+ return $self->_Set( Field => 'Category', Value => $value );
+}
=head2 Creator
commit 1a4beac4d8d288a632743ef6f82c99b249c5c69d
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Jul 14 16:01:19 2023 -0400
No need to explicitly set SubjectTag as it's NULL by default
As we support to actually set NULL since 955bea4696, these unnecessary
tests failed with "That is already the current value".
diff --git a/t/mail/charsets-outgoing-plaintext.t b/t/mail/charsets-outgoing-plaintext.t
index be576e0bda..4c358797d3 100644
--- a/t/mail/charsets-outgoing-plaintext.t
+++ b/t/mail/charsets-outgoing-plaintext.t
@@ -25,8 +25,7 @@ ok $queue && $queue->id, 'loaded or created queue';
diag "make sure queue has no subject tag";
{
- my ($status, $msg) = $queue->SetSubjectTag( undef );
- ok $status, "set subject tag for the queue" or diag "error: $msg";
+ ok !$queue->SubjectTag, "empty subject tag for the queue";
}
diag "set intial simple autoreply template";
diff --git a/t/mail/charsets-outgoing.t b/t/mail/charsets-outgoing.t
index 0f78f0a58e..0893ed9308 100644
--- a/t/mail/charsets-outgoing.t
+++ b/t/mail/charsets-outgoing.t
@@ -25,8 +25,7 @@ ok $queue && $queue->id, 'loaded or created queue';
diag "make sure queue has no subject tag";
{
- my ($status, $msg) = $queue->SetSubjectTag( undef );
- ok $status, "set subject tag for the queue" or diag "error: $msg";
+ ok !$queue->SubjectTag, "empty subject tag for the queue";
}
diag "set intial simple autoreply template";
commit 955bea4696d947d05fe46f9a48f3edf9141837b8
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Jul 14 15:32:41 2023 -0400
Allow to set columns to their default value or NULL
There are a few columns that have default values defined or could simply
be NULL, disallowing to set them back is annoying and not quite right.
The code converting NULL to 0 was created 2 decades ago at which time
SearchBuilder didn't support to pass undef values yet. SearchBuilder
supports it since 1.64(a decade ago), now it's safe to drop the obsolete
code.
diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
index 7828634bf0..fc08066d76 100644
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -453,13 +453,6 @@ sub _Set {
@_
);
- #if the user is trying to modify the record
- # TODO: document _why_ this code is here
-
- if ( ( !defined( $args{'Field'} ) ) || ( !defined( $args{'Value'} ) ) ) {
- $args{'Value'} = 0;
- }
-
my $old_val = $self->__Value($args{'Field'});
$self->_SetLastUpdated();
my $ret = $self->SUPER::_Set(
@@ -484,7 +477,7 @@ sub _Set {
"[_1] changed from [_2] to [_3]",
$self->loc( $args{'Field'} ),
( $old_val ? '"' . $old_val . '"' : $self->loc("(no value)") ),
- '"' . $self->__Value( $args{'Field'}) . '"',
+ '"' . ($self->__Value( $args{'Field'}) // '') . '"',
);
}
} else {
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list