IDEMPIERE-5567 Support of UUID as Key (FHCA-4195) (#2142)

- fix for scripts to avoid errors when the table doesn't have the ID column, for example updating AD_Ref_Table throws error because there is no AD_Ref_Table_ID
This commit is contained in:
Carlos Ruiz 2023-12-14 23:27:44 +01:00 committed by GitHub
parent b52fbbd3f2
commit 8bbdceae0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 26 additions and 18 deletions

View File

@ -167,7 +167,7 @@ BEGIN
FOR r IN (
SELECT DISTINCT t.TableName, cl.AD_Table_ID
FROM AD_ChangeLog cl
JOIN AD_Table t ON (cl.AD_Table_ID=t.AD_Table_ID)
JOIN AD_Table t ON (cl.AD_Table_ID=t.AD_Table_ID AND EXISTS (SELECT 1 FROM AD_Column WHERE ColumnName=t.TableName||'_ID'))
WHERE cl.Record_UU IS NULL
AND cl.Record_ID IS NOT NULL
AND cl.EventChangeLog!='D'

View File

@ -23,7 +23,7 @@ BEGIN
FOR r IN (
SELECT DISTINCT t.TableName, ri.AD_Table_ID
FROM AD_RecentItem ri
JOIN AD_Table t ON (ri.AD_Table_ID=t.AD_Table_ID)
JOIN AD_Table t ON (ri.AD_Table_ID=t.AD_Table_ID AND EXISTS (SELECT 1 FROM AD_Column WHERE ColumnName=t.TableName||'_ID'))
WHERE ri.Record_UU IS NULL
AND ri.Record_ID IS NOT NULL
) LOOP

View File

@ -249,7 +249,8 @@ DECLARE
BEGIN
FOR r IN (
SELECT DISTINCT t.TableName, at.AD_Table_ID
FROM AD_Attachment at JOIN AD_Table t ON (at.AD_Table_ID=t.AD_Table_ID)
FROM AD_Attachment at
JOIN AD_Table t ON (at.AD_Table_ID=t.AD_Table_ID AND EXISTS (SELECT 1 FROM AD_Column WHERE ColumnName=t.TableName||'_ID'))
WHERE at.Record_UU IS NULL AND at.Record_ID IS NOT NULL
) LOOP
cmd := 'UPDATE AD_Attachment SET Record_UU=(SELECT ' || r.TableName || '_UU FROM ' || r.TableName
@ -260,7 +261,8 @@ BEGIN
END LOOP;
FOR r IN (
SELECT DISTINCT t.TableName, ch.AD_Table_ID
FROM CM_Chat ch JOIN AD_Table t ON (ch.AD_Table_ID=t.AD_Table_ID)
FROM CM_Chat ch
JOIN AD_Table t ON (ch.AD_Table_ID=t.AD_Table_ID AND EXISTS (SELECT 1 FROM AD_Column WHERE ColumnName=t.TableName||'_ID'))
WHERE ch.Record_UU IS NULL AND ch.Record_ID IS NOT NULL
) LOOP
cmd := 'UPDATE CM_Chat SET Record_UU=(SELECT ' || r.TableName || '_UU FROM ' || r.TableName
@ -271,7 +273,8 @@ BEGIN
END LOOP;
FOR r IN (
SELECT DISTINCT t.TableName, po.AD_Table_ID
FROM AD_PostIt po JOIN AD_Table t ON (po.AD_Table_ID=t.AD_Table_ID)
FROM AD_PostIt po
JOIN AD_Table t ON (po.AD_Table_ID=t.AD_Table_ID AND EXISTS (SELECT 1 FROM AD_Column WHERE ColumnName=t.TableName||'_ID'))
WHERE po.Record_UU IS NULL AND po.Record_ID IS NOT NULL
) LOOP
cmd := 'UPDATE AD_PostIt SET Record_UU=(SELECT ' || r.TableName || '_UU FROM ' || r.TableName
@ -282,7 +285,8 @@ BEGIN
END LOOP;
FOR r IN (
SELECT DISTINCT t.TableName, la.AD_Table_ID
FROM AD_LabelAssignment la JOIN AD_Table t ON (la.AD_Table_ID=t.AD_Table_ID)
FROM AD_LabelAssignment la
JOIN AD_Table t ON (la.AD_Table_ID=t.AD_Table_ID AND EXISTS (SELECT 1 FROM AD_Column WHERE ColumnName=t.TableName||'_ID'))
WHERE la.Record_UU IS NULL AND la.Record_ID IS NOT NULL
) LOOP
cmd := 'UPDATE AD_LabelAssignment SET Record_UU=(SELECT ' || r.TableName || '_UU FROM ' || r.TableName

View File

@ -51,7 +51,7 @@ BEGIN
FOR r IN (
SELECT DISTINCT t.TableName, a.AD_Table_ID
FROM AD_Archive a
JOIN AD_Table t ON (a.AD_Table_ID=t.AD_Table_ID)
JOIN AD_Table t ON (a.AD_Table_ID=t.AD_Table_ID AND EXISTS (SELECT 1 FROM AD_Column WHERE ColumnName=t.TableName||'_ID'))
WHERE a.Record_UU IS NULL
AND a.Record_ID > 0
) LOOP

View File

@ -194,7 +194,7 @@ BEGIN
FOR r IN (
SELECT DISTINCT t.TableName, a.AD_Table_ID
FROM R_Request a
JOIN AD_Table t ON (a.AD_Table_ID=t.AD_Table_ID)
JOIN AD_Table t ON (a.AD_Table_ID=t.AD_Table_ID AND EXISTS (SELECT 1 FROM AD_Column WHERE ColumnName=t.TableName||'_ID'))
WHERE a.Record_UU IS NULL
AND a.Record_ID > 0
) LOOP

View File

@ -95,7 +95,7 @@ BEGIN
FOR r IN (
SELECT DISTINCT t.TableName, a.AD_Table_ID
FROM AD_Package_Imp_Detail a
JOIN AD_Table t ON (a.AD_Table_ID=t.AD_Table_ID)
JOIN AD_Table t ON (a.AD_Table_ID=t.AD_Table_ID AND EXISTS (SELECT 1 FROM AD_Column WHERE ColumnName=t.TableName||'_ID'))
WHERE a.Record_UU IS NULL
AND a.AD_Table_ID > 0
AND a.Record_ID > 0

View File

@ -164,7 +164,7 @@ BEGIN
FOR r IN
SELECT DISTINCT t.TableName, cl.AD_Table_ID
FROM AD_ChangeLog cl
JOIN AD_Table t ON (cl.AD_Table_ID=t.AD_Table_ID)
JOIN AD_Table t ON (cl.AD_Table_ID=t.AD_Table_ID AND EXISTS (SELECT 1 FROM AD_Column WHERE ColumnName=t.TableName||'_ID'))
WHERE cl.Record_UU IS NULL
AND cl.Record_ID IS NOT NULL
AND cl.EventChangeLog!='D'

View File

@ -20,7 +20,7 @@ BEGIN
FOR r IN
SELECT DISTINCT t.TableName, ri.AD_Table_ID
FROM AD_RecentItem ri
JOIN AD_Table t ON (ri.AD_Table_ID=t.AD_Table_ID)
JOIN AD_Table t ON (ri.AD_Table_ID=t.AD_Table_ID AND EXISTS (SELECT 1 FROM AD_Column WHERE ColumnName=t.TableName||'_ID'))
WHERE ri.Record_UU IS NULL
AND ri.Record_ID IS NOT NULL
LOOP

View File

@ -246,7 +246,8 @@ DECLARE
BEGIN
FOR r IN
SELECT DISTINCT t.TableName, at.AD_Table_ID
FROM AD_Attachment at JOIN AD_Table t ON (at.AD_Table_ID=t.AD_Table_ID)
FROM AD_Attachment at
JOIN AD_Table t ON (at.AD_Table_ID=t.AD_Table_ID AND EXISTS (SELECT 1 FROM AD_Column WHERE ColumnName=t.TableName||'_ID'))
WHERE at.Record_UU IS NULL AND at.Record_ID IS NOT NULL
LOOP
cmd := 'UPDATE AD_Attachment SET Record_UU=(SELECT ' || r.TableName || '_UU FROM ' || r.TableName
@ -258,7 +259,8 @@ BEGIN
END LOOP;
FOR r IN
SELECT DISTINCT t.TableName, ch.AD_Table_ID
FROM CM_Chat ch JOIN AD_Table t ON (ch.AD_Table_ID=t.AD_Table_ID)
FROM CM_Chat ch
JOIN AD_Table t ON (ch.AD_Table_ID=t.AD_Table_ID AND EXISTS (SELECT 1 FROM AD_Column WHERE ColumnName=t.TableName||'_ID'))
WHERE ch.Record_UU IS NULL AND ch.Record_ID IS NOT NULL
LOOP
cmd := 'UPDATE CM_Chat SET Record_UU=(SELECT ' || r.TableName || '_UU FROM ' || r.TableName
@ -270,7 +272,8 @@ BEGIN
END LOOP;
FOR r IN
SELECT DISTINCT t.TableName, po.AD_Table_ID
FROM AD_PostIt po JOIN AD_Table t ON (po.AD_Table_ID=t.AD_Table_ID)
FROM AD_PostIt po
JOIN AD_Table t ON (po.AD_Table_ID=t.AD_Table_ID AND EXISTS (SELECT 1 FROM AD_Column WHERE ColumnName=t.TableName||'_ID'))
WHERE po.Record_UU IS NULL AND po.Record_ID IS NOT NULL
LOOP
cmd := 'UPDATE AD_PostIt SET Record_UU=(SELECT ' || r.TableName || '_UU FROM ' || r.TableName
@ -282,7 +285,8 @@ BEGIN
END LOOP;
FOR r IN
SELECT DISTINCT t.TableName, la.AD_Table_ID
FROM AD_LabelAssignment la JOIN AD_Table t ON (la.AD_Table_ID=t.AD_Table_ID)
FROM AD_LabelAssignment la
JOIN AD_Table t ON (la.AD_Table_ID=t.AD_Table_ID AND EXISTS (SELECT 1 FROM AD_Column WHERE ColumnName=t.TableName||'_ID'))
WHERE la.Record_UU IS NULL AND la.Record_ID IS NOT NULL
LOOP
cmd := 'UPDATE AD_LabelAssignment SET Record_UU=(SELECT ' || r.TableName || '_UU FROM ' || r.TableName

View File

@ -47,7 +47,7 @@ BEGIN
FOR r IN
SELECT DISTINCT t.TableName, a.AD_Table_ID
FROM AD_Archive a
JOIN AD_Table t ON (a.AD_Table_ID=t.AD_Table_ID)
JOIN AD_Table t ON (a.AD_Table_ID=t.AD_Table_ID AND EXISTS (SELECT 1 FROM AD_Column WHERE ColumnName=t.TableName||'_ID'))
WHERE a.Record_UU IS NULL
AND a.Record_ID > 0
LOOP

View File

@ -191,7 +191,7 @@ BEGIN
FOR r IN
SELECT DISTINCT t.TableName, a.AD_Table_ID
FROM R_Request a
JOIN AD_Table t ON (a.AD_Table_ID=t.AD_Table_ID)
JOIN AD_Table t ON (a.AD_Table_ID=t.AD_Table_ID AND EXISTS (SELECT 1 FROM AD_Column WHERE ColumnName=t.TableName||'_ID'))
WHERE a.Record_UU IS NULL
AND a.Record_ID > 0
LOOP

View File

@ -91,7 +91,7 @@ BEGIN
FOR r IN
SELECT DISTINCT t.TableName, a.AD_Table_ID
FROM AD_Package_Imp_Detail a
JOIN AD_Table t ON (a.AD_Table_ID=t.AD_Table_ID)
JOIN AD_Table t ON (a.AD_Table_ID=t.AD_Table_ID AND EXISTS (SELECT 1 FROM AD_Column WHERE ColumnName=t.TableName||'_ID'))
WHERE a.Record_UU IS NULL
AND a.AD_Table_ID > 0
AND a.Record_ID > 0