Open ended type system #61

Closed
opened 2026-09-17 07:34:08 +02:00 by c.fahner · 0 comments
Owner

Currently the type system only allows types that reduce to one of the types described by the StorageClass enum. This is quite an inflexible system and has the potential to break any time a type must be added. It's also bad at denoting hierarchies.

The Type::serialize() method should be changed to allow a mixed return type, and the TypeInfo utility should only report types that are not mixed, null or DNF. Meaning that Type implementations must still explicitly override the return type hint of the serialize() method. The StorageClass enum should also be removed (see #60).

Additionally the Update statements that deal with adding/setting data must be changed to allow mixed.

Implementations may reject types they don't recognize, but for conformance they must pass the "basic types" test (tracked via slendium/ocd-conformance-tests#6). The basic types to support would be DateTimeInterface, BackedEnum, Blob, array (to enable compound types stored as JSON in SQL databases), string, float, int and bool.

For the DateTimeInterface specifically, support must be added to the relevant Predicate\Expr types that deal with equality/comparison. The Predicate\DocumentShape utility must be expanded with the following methods (which should also be documented at the top of the class):

  • before(DateTimeInterface)
  • onOrBefore(DateTimeInterface)
  • after(DateTimeInterface)
  • onOrAfter(DateTimeInterface)

Issues #37 and #4 are now obsolete.

Update 2026-09-20: Provide type implementations for the missing basic types: enumerations, date/times and arrays (which will default to generic maps).

Currently the type system only allows types that reduce to one of the types described by the `StorageClass` enum. This is quite an inflexible system and has the potential to break any time a type must be added. It's also bad at denoting hierarchies. The `Type::serialize()` method should be changed to allow a `mixed` return type, and the `TypeInfo` utility should only report types that are not `mixed`, `null` or DNF. Meaning that `Type` implementations must still explicitly override the return type hint of the `serialize()` method. The `StorageClass` enum should also be removed (see #60). Additionally the `Update` statements that deal with adding/setting data must be changed to allow `mixed`. Implementations may reject types they don't recognize, but for conformance they must pass the "basic types" test (tracked via slendium/ocd-conformance-tests#6). The basic types to support would be `DateTimeInterface`, `BackedEnum`, `Blob`, `array` (to enable compound types stored as JSON in SQL databases), `string`, `float`, `int` and `bool`. For the `DateTimeInterface` specifically, support must be added to the relevant `Predicate\Expr` types that deal with equality/comparison. The `Predicate\DocumentShape` utility must be expanded with the following methods (which should also be documented at the top of the class): * `before(DateTimeInterface)` * `onOrBefore(DateTimeInterface)` * `after(DateTimeInterface)` * `onOrAfter(DateTimeInterface)` Issues #37 and #4 are now obsolete. Update 2026-09-20: Provide type implementations for the missing basic types: enumerations, date/times and arrays (which will default to generic maps).
c.fahner added this to the v0.2 milestone 2026-09-17 07:34:08 +02:00
c.fahner stopped working 2026-09-20 08:44:21 +02:00
1 hour 44 minutes
c.fahner added spent time 2026-09-20 08:44:31 +02:00
1 hour 30 minutes
c.fahner stopped working 2026-09-20 11:38:45 +02:00
1 hour 11 minutes
c.fahner stopped working 2026-09-21 15:40:22 +02:00
25 minutes 24 seconds
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Total time spent: 4 hours 50 minutes
c.fahner
4 hours 50 minutes
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
slendium/ocd#61
No description provided.