Skip to content

Add validate_schema parameter for strict field validation#1

Merged
richardwooding merged 1 commit intomainfrom
feat/validate-schema
Feb 27, 2026
Merged

Add validate_schema parameter for strict field validation#1
richardwooding merged 1 commit intomainfrom
feat/validate-schema

Conversation

@richardwooding
Copy link
Contributor

Summary

  • Add validate_schema: bool = False parameter to convert(), convert_parameterized(), and analyze()
  • When enabled, raises InvalidSchemaError for unrecognized table or field references in table.field expressions, catching typos and references to nonexistent fields
  • Skips validation for comprehension variables, bare identifiers, and nested JSON keys beyond the first field
  • Export InvalidSchemaError from pycel2sql public API
  • Document the feature in README.md and CLAUDE.md

Test plan

  • 19 new tests in tests/test_validate_schema.py covering config, field access, JSON, comprehensions, bare idents, and all three public API functions
  • All 607 unit tests pass
  • Ruff linting clean
  • mypy shows only pre-existing lark type errors

🤖 Generated with Claude Code

When validate_schema=True, convert()/convert_parameterized()/analyze()
raise InvalidSchemaError for unrecognized table or field references in
table.field expressions. This catches typos and references to nonexistent
fields that would otherwise silently produce incorrect SQL.

Validation skips comprehension variables, bare identifiers, and nested
JSON keys beyond the first field. Requires schemas to be provided.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@richardwooding richardwooding merged commit 7197f63 into main Feb 27, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant