2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-06-15 10:50:28 +00:00

Set value to '' if value within composite primary keys not defined (#2045)

As history reasons, null value is always set within the composite primary
keys, this patch is just a work aroud for the issue encountered on postgres.
Correct fix is to report error to the client side, but too much error handler
is missing in xcat code

close-issue: #2037
close-issue: #2007
This commit is contained in:
chenglch
2016-11-01 10:14:54 +08:00
committed by yangsong
parent f2eeaa37eb
commit 331d7868fa

View File

@ -1722,6 +1722,16 @@ sub setAttribs
@bind = ();
$cols = "";
my %newpairs;
# NOTE(chenglch): Just work around, set the default value to '' due to
# null value can not be allowed in composite primary keys in standard
# SQL rules.
my $descr = $xCAT::Schema::tabspec{ $self->{tabname} };
my @pkeys = @{$descr->{keys}};
for my $p (@pkeys) {
if(!defined($elems->{$p}) && !defined($pKeypairs->{$p})) {
$elems->{$p}= '';
}
}
#first, merge the two structures to a single hash
foreach (keys %keypairs)