Skip to content

Conversation

@richardwooding
Copy link
Contributor

Summary

Fixes #30 - Type Provider now fails fast on unknown PostgreSQL types instead of silently defaulting to string.

Problem

Previously, FindStructFieldType() defaulted unknown PostgreSQL types (UUID, INET, geometric types, custom enums) to decls.String, causing:

  • ❌ Incorrect SQL generation (wrong operators for type)
  • ❌ Type mismatches in comparisons
  • ❌ Silent failures that are hard to debug

Solution

1. Added Explicit Support for Common PostgreSQL Types

  • UUIDdecls.Bytes
  • INET, CIDRdecls.String (network addresses)
  • MACADDR, MACADDR8decls.String (MAC addresses)
  • XMLdecls.String
  • MONEYdecls.Double
  • TSVECTOR, TSQUERYdecls.String (full-text search)

2. Changed Default Behavior

Unknown PostgreSQL types now return found=false instead of defaulting to string. This provides:

  • ✅ Clear errors at type provider creation
  • ✅ Prevention of silent type mismatches
  • ✅ Better type safety and debugging

3. Comprehensive Testing

  • Added Test_typeProvider_PostgreSQLTypes with 13 test cases
  • Tests all newly supported types
  • Tests arrays of new types
  • Tests unknown types correctly return found=false

4. Updated Documentation

  • Reorganized CLAUDE.md Type System Integration section
  • Documented all supported PostgreSQL types by category
  • Added note about unsupported types behavior

Breaking Change ⚠️

Code using unsupported PostgreSQL types (e.g., point, polygon, box, custom enums) will now fail at type provider creation instead of silently converting to string.

Migration: Add explicit support for custom types or use composite type definitions in your schema.

Testing

  • ✅ All existing tests pass
  • ✅ All new tests pass
  • ✅ Full test suite: go test ./... passes

Checklist

  • Code follows project conventions
  • Tests added for new functionality
  • Documentation updated
  • All tests passing
  • Breaking change documented

🤖 Generated with Claude Code

…fixes #30)

Changes:
- Added explicit support for UUID, INET, CIDR, MACADDR, XML, MONEY, TSVECTOR, TSQUERY
- Unknown PostgreSQL types now return found=false instead of silently becoming strings
- Prevents silent type mismatches and incorrect SQL generation
- Added comprehensive tests for all newly supported types
- Updated CLAUDE.md with complete PostgreSQL type mapping documentation

Breaking Change: Code using unsupported PostgreSQL types will now fail at type
provider creation instead of silently converting to string. This provides better
type safety and prevents hard-to-debug SQL generation issues.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@richardwooding richardwooding merged commit 708e6f6 into main Oct 24, 2025
9 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.

Type Provider Silently Defaults Unknown Types to String

1 participant