From 1ad8f446c99afb3fc52e108f09aea52cedf440a1 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 25 Nov 2022 10:02:24 +0000 Subject: [PATCH] Bug 32350: Use array_minus and ignore nesting Content-Type: text/plain; charset=utf-8 Note: Test will be extended in follow-up. This fixes the module_bit hash to follow the FK path from user_permissions to permissions to userflags. One step was missed in the existing test, although it did not fail. The change here revealed that now. Test plan: Run t/db_dependent/TestBuilder.t Signed-off-by: Marcel de Rooy Signed-off-by: Martin Renvoize --- t/db_dependent/TestBuilder.t | 4 +++- t/lib/TestBuilder.pm | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/TestBuilder.t b/t/db_dependent/TestBuilder.t index c256fe53fc..30588da103 100755 --- a/t/db_dependent/TestBuilder.t +++ b/t/db_dependent/TestBuilder.t @@ -244,7 +244,9 @@ sub default_userpermission { privacy => 1, }, module_bit => { - flag => 'my flag', + module_bit => { + flag => 'my flag', + }, }, code => { code => 'my code', diff --git a/t/lib/TestBuilder.pm b/t/lib/TestBuilder.pm index d065835ded..95699392c6 100644 --- a/t/lib/TestBuilder.pm +++ b/t/lib/TestBuilder.pm @@ -12,6 +12,7 @@ use Bytes::Random::Secure; use Carp qw( carp ); use Module::Load qw( load ); use String::Random; +use Array::Utils qw( array_minus ); use constant { SIZE_BARCODE => 20, # Not perfect but avoid to fetch the value when creating a new item @@ -280,6 +281,10 @@ sub _buildColumnValues { my @columns = $self->schema->source($source)->columns; my %unique_constraints = $self->schema->source($source)->unique_constraints(); + my @passed_keys = grep { ref($original_value->{$_}) ne 'HASH' } keys %$original_value; + my @minus = array_minus( @passed_keys, @columns ); + die "Error: value hash contains unrecognized columns: ". (join ',', @minus) if @minus; + my $build_value = 5; # we try max $build_value times if there are unique constraints BUILD_VALUE: while ( $build_value ) { -- 2.30.2