{
  "schema": "vedokrok.public-item.v1",
  "release_id": "VEDOKROK-SEL-5d86e1b23401e578",
  "url": "/knowledge/detect-changes-involving-null",
  "id": "MHC-D-RESEARCH-9720",
  "version": "0.1.0",
  "title": "Detect changes involving NULL",
  "summary": "'Not equal' can be unknown, not true.",
  "kind": "protocol",
  "body": "Ordinary SQL <> (not equal) returns UNKNOWN when either value is NULL, so a filter using it can miss a difference. For scalar values in PostgreSQL, IS DISTINCT FROM returns true when one value is NULL and the other is present; two NULLs return false. Use your database's supported comparison, then decide what the detected difference should do.",
  "limits": [
    "These comparison results do not define update intent. Check syntax and behavior in your own database; the example covers scalar values."
  ],
  "topics": [
    "critical-thinking"
  ],
  "intents": [],
  "source_ids": [
    "pg-null"
  ],
  "evidence": [
    {
      "claim": "In PostgreSQL, ordinary comparisons involving NULL yield unknown; IS [NOT] DISTINCT FROM treats NULL as a comparable value.",
      "source_id": "pg-null",
      "role": "supports",
      "note": "Claim limit: Scalar comparisons in PostgreSQL 18. Composite keys and other engines require their own matching rules; this is not a query-planner guarantee.\nSource reading history: selected_passages; 2026-10-11; Section 9.2 Comparison Functions and Operators. Version 18 comparison passages rechecked on 2026-10-11: ordinary comparisons involving NULL and IS [NOT] DISTINCT FROM. Source reading is not production testing or proof of the drafted workflow.\nAgent release review: PostgreSQL 18 table expressions, NULL comparisons and aggregates, the UK Government Data Quality Framework and Microsoft Power Query profiling documentation were checked at the cited sections. The original examples and scope limits remain attached.",
      "locator": "Section 9.2 Comparison Functions and Operators"
    }
  ],
  "use_when": [
    "You compare source and target values before a data sync."
  ],
  "avoid_when": [
    "These comparison results do not define update intent. Check syntax and behavior in your own database; the example covers scalar values."
  ],
  "steps": [
    "Test five pairs: equal values, unequal values, NULL/NULL, value/NULL and NULL/value.",
    "Define whether an incoming NULL means clear the field, unknown or no update. Keep an empty string separate unless your data rules equate it with NULL."
  ],
  "example": "If the agreed rule says NULL clears a phone number, changing '123' to NULL needs an update. If NULL means no update, detecting the difference alone must not clear the number.",
  "check": "With IS DISTINCT FROM, the five pairs return false, true, false, true and true respectively. The update also follows the agreed meaning of NULL.",
  "published_at": "2026-11-12T18:37:40Z",
  "review": {
    "kind": "agent",
    "label": "Agent editorial and scoped source review",
    "reviewed_at": "2026-11-12T18:37:40Z"
  },
  "knowledge_origin": {
    "release_id": "MHC-RPUB-20261112-20287590",
    "corpus_commit": "20287590ddd3999b7492df232822b6a0f7d114b1",
    "manifest_sha256": "2a987660d12de0ce2bde77a421424f7762af1ff77872ef41093fecc33db74a95",
    "projection_sha256": "2807da39bbe6a3dee2db32a76675ac5185f5a33e8b0a5cdd0c22a4731f3378a0",
    "published_at": "2026-11-12T18:37:40Z"
  },
  "editorial_overlay": null,
  "editorial": null,
  "notices": [],
  "sources": [
    {
      "id": "pg-null",
      "title": "PostgreSQL 18: Comparison Functions and Operators",
      "url": "https://www.postgresql.org/docs/18/functions-comparison.html"
    }
  ],
  "relations": [
    {
      "from": "MHC-D-RESEARCH-9720",
      "to": "MHC-D-RESEARCH-9728",
      "type": "useful_with",
      "url": "/knowledge/count-rows-and-non-null-values-separately"
    }
  ],
  "collections": [
    {
      "id": "RC-MHC-UNION-DATA-JOINS-QUALITY-DIAGNOSTICS-2026",
      "title": "Diagnose data joins and quality before trusting a report",
      "url": "/collections/diagnose-data-joins-and-quality-before-trusting-a-report"
    }
  ],
  "topic_hubs": [
    {
      "id": "critical-thinking",
      "title": "Critical thinking and evidence",
      "url": "/topics/critical-thinking"
    }
  ],
  "solution_packs": []
}
