Add opt-in SQL root-level projected columns for repository stores#763
Add opt-in SQL root-level projected columns for repository stores#763Copilot wants to merge 10 commits into
Conversation
Agent-Logs-Url: https://github.com/effect-app/libs/sessions/f324ecdc-fbb7-4471-9947-241bf85170ff Co-authored-by: patroza <42661+patroza@users.noreply.github.com>
Agent-Logs-Url: https://github.com/effect-app/libs/sessions/f324ecdc-fbb7-4471-9947-241bf85170ff Co-authored-by: patroza <42661+patroza@users.noreply.github.com>
Agent-Logs-Url: https://github.com/effect-app/libs/sessions/f324ecdc-fbb7-4471-9947-241bf85170ff Co-authored-by: patroza <42661+patroza@users.noreply.github.com>
Agent-Logs-Url: https://github.com/effect-app/libs/sessions/f324ecdc-fbb7-4471-9947-241bf85170ff Co-authored-by: patroza <42661+patroza@users.noreply.github.com>
@effect-app/cli
effect-app
@effect-app/eslint-codegen-model
@effect-app/eslint-shared-config
@effect-app/infra
@effect-app/vue
@effect-app/vue-components
commit: |
|
@copilot document the plan for next step; relational fields |
Agent-Logs-Url: https://github.com/effect-app/libs/sessions/ffdbe97c-c62f-4ae1-8a79-57e8f539221a Co-authored-by: patroza <42661+patroza@users.noreply.github.com>
|
@copilot don't write the separate fields also to data. and support any field type, including complex types, which should simply be json fields, like data is. |
Agent-Logs-Url: https://github.com/effect-app/libs/sessions/2c26dc3a-b352-4999-b5d5-98349e52640c Co-authored-by: patroza <42661+patroza@users.noreply.github.com>
Agent-Logs-Url: https://github.com/effect-app/libs/sessions/2c26dc3a-b352-4999-b5d5-98349e52640c Co-authored-by: patroza <42661+patroza@users.noreply.github.com>
Agent-Logs-Url: https://github.com/effect-app/libs/sessions/2c26dc3a-b352-4999-b5d5-98349e52640c Co-authored-by: patroza <42661+patroza@users.noreply.github.com>
Addressed in 93db22d. Projected root fields are no longer duplicated into |
|
@copilot you misunderstood rootLevelFieldsWhenAvailable setting; the when available is about when database adapters usually use data column, when the setting is enabled you should switch to using root level columns and do migrations when there are schema changes. you should not support both at the same time, with fallbacks. A migration of data should also happen offline, not on the fly. Queries and writes should either be to data column when setting is omitted/false, and to columns when true |
Agent-Logs-Url: https://github.com/effect-app/libs/sessions/18e97927-7b93-4bc4-aefc-a0461aa0331e Co-authored-by: patroza <42661+patroza@users.noreply.github.com>
Agent-Logs-Url: https://github.com/effect-app/libs/sessions/18e97927-7b93-4bc4-aefc-a0461aa0331e Co-authored-by: patroza <42661+patroza@users.noreply.github.com>
Addressed in 34fb23e, with cleanup in 0b3b0b9. |
This splits the storage evolution into the first track only: keep the current document model and JSON-based nested semantics, while allowing SQLite/PostgreSQL repositories to switch root-level fields to real columns. The new mode is opt-in per repository or adapter via
rootLevelFieldsWhenAvailable.What changed
rootLevelFieldsWhenAvailable?: booleanto repository/store config, with adapter-level default support in SQL storage config.data.false/ omitted: reads, writes, and queries usedatatrue: derived root fields are read, written, and queried via dedicated root columnsSchema-derived projected columns
stringnumberbooleanJSON/JSONBcolumns.SQLite / PostgreSQL store behavior
dataCOALESCE(...)fallback from projected columns back todatadataALTER TABLE/ migration behavior for existing rowsQuery planning
datacolumn.Tests
dataExample:
With that enabled, root-level fields are stored in dedicated SQL columns when available. Scalars use typed columns where possible, while complex root fields use JSON/JSONB columns. Projected fields are not duplicated into
data, and projected-mode reads/writes/queries use the root columns instead of falling back todata.