From dfb351e955839d7719bb3264c5cbeb6f10d7db0d Mon Sep 17 00:00:00 2001 From: Rene Krenn Date: Mon, 5 Apr 2021 21:07:10 +0200 Subject: [PATCH] TT#118050 skip NULL values for mssql INDENTITY columns Change-Id: I464a4645bf6a19299bbb46f3824974bc72113a42 (cherry picked from commit b4a70b1c9c55421984cf5e5b690d29a7c6dd114e) --- lib/NGCP/BulkProcessor/SqlProcessor.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/NGCP/BulkProcessor/SqlProcessor.pm b/lib/NGCP/BulkProcessor/SqlProcessor.pm index 5c52f03..3542f96 100644 --- a/lib/NGCP/BulkProcessor/SqlProcessor.pm +++ b/lib/NGCP/BulkProcessor/SqlProcessor.pm @@ -715,11 +715,14 @@ sub update_record { sub insert_stmt { - my ($get_db,$class,$insert_ignore) = @_; + my ($get_db,$class,$insert_ignore,$exclude_identity_fieldnames) = @_; my $db = (ref $get_db eq 'CODE') ? &$get_db() : $get_db; my $connectidentifier = $db->connectidentifier(); my $tid = threadid(); my $expected_fieldnames = $table_expected_fieldnames->{$tid}->{$connectidentifier}->{$class}; + if ($exclude_identity_fieldnames) { + $expected_fieldnames = [ grep { not contains($_,$exclude_identity_fieldnames); } @$expected_fieldnames ]; + } my $tablename = $table_names->{$tid}->{$connectidentifier}->{$class}; return 'INSERT ' . ($insert_ignore ? $db->insert_ignore_phrase() . ' ' : '') . 'INTO ' . $db->tableidentifier($tablename) . ' (' . join(', ',map { local $_ = $_; $_ = $db->columnidentifier($_); $_; } @$expected_fieldnames) .