Skip to content

Modernize CEL API usage: Remove deprecated ref.TypeProvider and ref.FieldType #1

@richardwooding

Description

@richardwooding

Summary

The current implementation uses deprecated CEL API types:

  • ref.TypeProvider (deprecated in favor of types.Provider)
  • ref.FieldType (deprecated in favor of types.FieldType)

Changes Needed

Provider Interface

  • Update TypeProvider interface to embed types.Provider instead of ref.TypeProvider
  • Implement modern types.Provider methods:
    • FindStructType(string) (*types.Type, bool)
    • FindStructFieldNames(string) ([]string, bool)
    • FindStructFieldType(string, string) (*types.FieldType, bool)
    • NewValue(string, map[string]ref.Val) ref.Val

Tests

  • Update pg/provider_test.go to use modern API
    • Replace FindType() calls with FindStructType()
    • Replace FindFieldType() calls with FindStructFieldType()
    • Update test expectations from *exprpb.Type to *types.Type
    • Update test expectations from *ref.FieldType to *types.FieldType
  • Update pg/provider_testcontainer_test.go to use modern API

Backward Compatibility

  • Consider adding a compatibility layer if external users depend on the old interface
  • Document migration path for users upgrading to the new API

Benefits

  • Future-proof against CEL API changes
  • Remove deprecation warnings from linter
  • Align with modern CEL best practices
  • Cleaner type system integration

Implementation Status

  • Interface updated to use types.Provider
  • Modern methods implemented
  • Tests updated (in progress)
  • Backward compatibility considered

This modernization ensures cel2sql remains compatible with current and future CEL versions while providing a cleaner, more maintainable API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions