Commit 98889ccb authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Correction de bug : le sync_non_importable ne fonctionnait pas!!!

parent 547f6954
Loading
Loading
Loading
Loading
Loading
+6 −6
Changes for src/Service/QueryGeneratorService.php: 6 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -487,6 +487,9 @@ class QueryGeneratorService extends AbstractService
        foreach ($cols as $id => $col) {
            $cols[$id] = $schema[$col];
        }

        $sio = !$table->getSyncNonImportables();

        $sql = "CREATE OR REPLACE FORCE VIEW V_DIFF_$tableName AS
select diff.* from (SELECT
  D.id id,
@@ -513,7 +516,9 @@ select diff.* from (SELECT
FROM
  $tableName D$depJoin
  FULL JOIN SRC_$tableName S ON $joinCond
  " . ($sio ? 'LEFT JOIN source ds ON ds.id = d.source_id' : '') . "
WHERE
  " . ($sio ? 'COALESCE(ds.importable,1) = 1 AND (' : '') . "
     (S.source_code IS NOT NULL AND D.source_code IS NOT NULL AND D.histo_destruction IS NOT NULL AND D.histo_destruction <= SYSDATE)
  OR (S.source_code IS NULL AND D.source_code IS NOT NULL AND (D.histo_destruction IS NULL OR D.histo_destruction > SYSDATE))
  OR (S.source_code IS NOT NULL AND D.source_code IS NULL)
@@ -524,12 +529,7 @@ WHERE
                    return 'D.:column <> S.:column OR (D.:column IS NULL AND S.:column IS NOT NULL) OR (D.:column IS NOT NULL AND S.:column IS NULL)';
                }
            }, "\n  OR ") . "
) diff JOIN source on source.id = diff.source_id WHERE import_action IS NOT NULL";
        if (!$table->getSyncNonImportables()) {
            $sql .= " AND source.importable = 1";
        }else{
            $sql .= " AND NOT (source.importable = 0 AND import_action='delete')";
        }
" . ($sio ? ')' : '') . ") diff WHERE import_action IS NOT NULL";

        return $sql;
    }