Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/GADS/Datum/Code.pm
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ sub write_cache
my $formatter = $self->schema->storage->datetime_parser;

my @values = sort @{$self->value} if defined $self->value->[0];
# If the length is greater than 250 characters do not insert it to the cache table
return \@values if grep { $_ > 250 } map { length($_) } @values;

# We are generally already in a transaction at this point, but
# start another one just in case
Expand Down
20 changes: 20 additions & 0 deletions t/007_code_cache.t
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,24 @@ is_deeply([map $_->value_int, $urs->all], $expected, "Correct values for cached
is_deeply([map $_->value_text, $urs->all], $expected, "Correct values for cached table after change to int");
}

{
my $expected_calc_val = "This is a really long string, longer than before, to test caching of long strings should fail gracefully and not put any extra values in the cache, this is to test the edge case handling of long strings in cached unique values because they break the cache in some really weird ways sometimes";
$record->clear;
$record->find_current_id(1);
$calc1->code("
function evaluate (L1string1)
return L1string1
end
");
$calc1->return_type('string');
$calc1->write;
$record->fields->{$string1->id}->set_value($expected_calc_val);
$record->write(no_alerts => 1);

is_deeply([map $_->value_text, $urs->all], [qw/Bar7 Bar8/], "Correct values for cached table after long string write");

my $calc_val = $record->fields->{$string1->id}->as_string;
is($calc_val, $expected_calc_val, "Correct value returned from calc after long string write");
}

done_testing();
Loading