Skip to content

Separate POCO defaults from value-expression evaluation in TableOperations#37

Open
ritchiecarroll wants to merge 1 commit into
developmentfrom
refactor-table-operations
Open

Separate POCO defaults from value-expression evaluation in TableOperations#37
ritchiecarroll wants to merge 1 commit into
developmentfrom
refactor-table-operations

Conversation

@ritchiecarroll

@ritchiecarroll ritchiecarroll commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Decouples TableOperations<T> from the Gemstone.Expressions type registry so the common "just construct and go" case works without any external setup.

Previously, TableOperations<T>.NewRecord() always evaluated attribute-based value expressions (DefaultValueExpressionAttribute / UpdateValueExpressionAttribute) against the type registry. When a model expression referenced an uninitialized dependency (e.g. Settings), simple usage such as new TableOperations<Device>(connection).NewRecord() would throw — an unknowable hidden dependency for a casual user.

Changes

  • TableOperations<T> is now pure POCO. It honors only the standard System.ComponentModel.DefaultValueAttribute via a self-contained compiled applier built with System.Linq.Expressions — no type-registry / Settings coupling. Removed the expression scope, the three expression delegates, InitializeType(), and the static TypeRegistry property.
  • New ExpressionTableOperations<T> : TableOperations<T> is the opt-in surface that restores the full value-expression behavior (a strict superset, identical to the prior default). Callers using it own the responsibility of initializing any dependencies their expressions reference.
  • Added three protected virtual seams (CreateRecordInstance, ApplyRecordDefaultValues, ApplyRecordUpdateValues) that the derived type overrides.
  • SecureTableOperations<T> now wraps ExpressionTableOperations<T> to preserve existing behavior.

Verification

  • Gemstone.Data builds clean (0 errors).
  • New DB-free unit tests (TableOperationsDefaultsTest) confirm: base NewRecord() applies [DefaultValue] but does not evaluate expressions; ExpressionTableOperations<T>.NewRecord() evaluates both.

Breaking change

External callers relying on the base TableOperations<T> to auto-evaluate value expressions must switch to ExpressionTableOperations<T>.

Related PRs

This is the core library change. Consumer updates:

🤖 Generated with Claude Code

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