Python Team: Document Status PascalCase Standardization
📋 Overview
The C# team has standardized all Document and Dossier status/type properties to use PascalCase in Neo4j. This document explains what changed, why, and what you need to verify in Python.
🎯 What Changed in C
Before (Mixed Case - PROBLEMATIC):
- C# wrote:
"ready","notyetprocessed","failed"(lowercase) - Python wrote:
"Ready","NotYetProcessed","Failed"(PascalCase) - Result: Database had inconsistent values
After (PascalCase Standard - CONSISTENT):
- C# now writes:
"Ready","NotYetProcessed","Failed","Processing","Optimizing"(PascalCase) - Python writes:
"Ready","NotYetProcessed","Failed","Processing","Optimizing"(PascalCase) - Result: Consistent database values across all services
📊 Affected Properties in Neo4j
Document Node Properties:
d.status→ Must be:"Ready","NotYetProcessed","Processing","Optimizing","Failed", or"NeedsCategorization"d.type→ Must be:"PDF","Text","Image","Docx","Xml","Html","Csv","MD", or"Other"
Dossier Node Properties:
dossier.type→ Must use PascalCase (whatever your enum values are)
✅ Action Items for Python Team
1. Verify Python Code Uses PascalCase ✓
Check that your Python services write these exact strings (case-sensitive):
# ✅ CORRECT - PascalCase
document.status = "NotYetProcessed"
document.status = "Ready"
document.status = "Processing"
document.status = "Failed"
document.status = "Optimizing"
document.type = "PDF"
document.type = "Text"
document.type = "Other"
# ❌ WRONG - lowercase
document.status = "notyetprocessed" # Will fail queries
document.status = "ready" # Will fail queries
Search your codebase for:
grep -r "notyetprocessed\|ready\|processing\|failed" --include="*.py"
grep -r "pdf\|text\|other" --include="*.py"
2. Update Neo4j Queries ⚠️
BEFORE (defensive with toLower):
MATCH (d:Document)
WHERE toLower(d.status) = 'notyetprocessed' # Slow - function call
RETURN d
AFTER (direct PascalCase comparison):
MATCH (d:Document)
WHERE d.status = 'NotYetProcessed' # Fast - direct comparison
RETURN d
Benefits: - ⚡ Faster queries (no toLower() function overhead) - 🎯 Index optimization (Neo4j can use indexes efficiently) - 🐛 Fewer bugs (exact string matching, no case ambiguity)
3. Clean Up Existing Database 🧹
Your database audit found these inconsistent values:
| Value | Count | Action Required |
|---|---|---|
"NotYetProcessed" |
50,875 | ✅ Already correct |
"Ready" |
3,999 | ✅ Already correct |
"ready" |
41 | ⚠️ Update to "Ready" |
"notyetprocessed" |
5 | ⚠️ Update to "NotYetProcessed" |
Cleanup Script Example:
// Fix lowercase "ready" → "Ready"
MATCH (d:Document)
WHERE d.status = 'ready'
SET d.status = 'Ready'
RETURN count(d) as updated;
// Fix lowercase "notyetprocessed" → "NotYetProcessed"
MATCH (d:Document)
WHERE d.status = 'notyetprocessed'
SET d.status = 'NotYetProcessed'
RETURN count(d) as updated;
// Verify no lowercase values remain
MATCH (d:Document)
WHERE toLower(d.status) <> d.status // Case mismatch
RETURN d.status, count(*) as count;
4. Update Python Enums (if applicable) 📝
If you have Python enums, ensure they match:
from enum import Enum
class DocumentStatus(Enum):
READY = "Ready" # ✅ PascalCase string
NOT_YET_PROCESSED = "NotYetProcessed" # ✅ PascalCase string
PROCESSING = "Processing" # ✅ PascalCase string
OPTIMIZING = "Optimizing" # ✅ PascalCase string
FAILED = "Failed" # ✅ PascalCase string
class DocumentType(Enum):
PDF = "PDF" # ✅ All caps for acronym
TEXT = "Text" # ✅ PascalCase
IMAGE = "Image" # ✅ PascalCase
DOCX = "Docx" # ✅ PascalCase
XML = "Xml" # ✅ All caps for acronym
HTML = "Html" # ✅ All caps for acronym
OTHER = "Other" # ✅ PascalCase
Usage:
# ✅ Correct
doc["status"] = DocumentStatus.NOT_YET_PROCESSED.value # "NotYetProcessed"
# ❌ Wrong
doc["status"] = DocumentStatus.NOT_YET_PROCESSED.name # "NOT_YET_PROCESSED"
doc["status"] = "notyetprocessed" # lowercase
🔍 Testing Checklist
- [ ] Search Python code for lowercase status/type strings
- [ ] Update any hardcoded lowercase strings to PascalCase
- [ ] Remove
toLower()or.lower()calls from Neo4j queries - [ ] Run cleanup script to fix existing database values
- [ ] Test document creation → verify status is
"NotYetProcessed"(not"notyetprocessed") - [ ] Test document processing → verify status changes to
"Processing", then"Ready" - [ ] Query Neo4j to confirm no lowercase values remain
📚 Reference: Valid Values
DocumentStatus (PascalCase):
"Ready"
"Processing"
"Optimizing"
"NotYetProcessed"
"Failed"
"NeedsCategorization"
DocumentType (PascalCase):
"PDF" // All caps for acronym
"Text"
"Image"
"Docx"
"Xml" // All caps for acronym
"Html" // All caps for acronym
"Csv" // All caps for acronym
"MD" // All caps for acronym
"Other"
🤝 Cross-Team Consistency
C# Side (completed):
- ✅ Removed .ToLower() from Save methods
- ✅ Removed toLower() from all Neo4j queries
- ✅ Now writes PascalCase values to database
- ✅ Queries use direct string comparison (faster)
Python Side (your action):
- ⚠️ Verify Python writes PascalCase values
- ⚠️ Update queries to use PascalCase (remove .lower())
- ⚠️ Clean up existing lowercase database values
🐛 Common Pitfalls
❌ WRONG:
# Case mismatch - will NOT match database values
query = """
MATCH (d:Document)
WHERE d.status = 'ready' // lowercase won't match "Ready" in DB
RETURN d
"""
# Using .lower() unnecessarily
status = document_status.lower() # Creates "ready" instead of "Ready"
✅ CORRECT:
# Exact case match
query = """
MATCH (d:Document)
WHERE d.status = 'Ready' // Matches database exactly
RETURN d
"""
# Use PascalCase directly
status = "Ready" # Matches database exactly
📞 Questions?
Contact the C# team if you need clarification on: - Exact case formatting for any specific enum value - Query performance optimization strategies - Database migration timing/coordination
Bottom line: All status and type values in Neo4j must now use PascalCase for consistency and performance. No more toLower() conversions needed!