You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To make defining common database patterns easier and more efficient in DBML, we're proposing a new feature: TablePartial.
The core idea is to allow you to define reusable blocks of columns, indexes, and settings that can be easily included in multiple table definitions. Think of standard audit trails (created_at, updated_at), soft delete fields, or common indexing patterns.
This syntax is inspired by and aims to address many of the ideas and suggestions raised in the following discussions and issues:
We explored various ways to achieve reusability. The chosen approach, using TablePartial with the ~ include syntax, functions like composition or mixins - the contents of the partial are effectively copied directly into the target table definition ("auto-inject").
We opted for this composition model over implementing OOP-style table inheritance for several reasons:
Simplicity & Clarity: Composition leads to a very clear final table structure. All columns and indexes are explicitly present in the resulting definition, making it easy to understand the final schema without tracing an inheritance hierarchy.
Alignment with DBML's Purpose: DBML is primarily a database-agnostic, declarative language for defining database schemas. True inheritance introduces complexities that don't directly map well to standard relational database structures and could complicate the language unnecessarily.
Database Reality: Relational databases don't usually support native table inheritance. The composition approach more closely reflects how reusable patterns (like standard audit columns) are implemented in practice—by adding the necessary columns directly to each relevant table.
Flexibility: It allows mixing and matching multiple partials easily without the potential conflicts or complexities associated with multiple inheritance paradigms.
We'd love your feedback on this proposal! Please share your thoughts below.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi everyone,
To make defining common database patterns easier and more efficient in DBML, we're proposing a new feature:
TablePartial.The core idea is to allow you to define reusable blocks of columns, indexes, and settings that can be easily included in multiple table definitions. Think of standard audit trails (
created_at,updated_at), soft delete fields, or common indexing patterns.This syntax is inspired by and aims to address many of the ideas and suggestions raised in the following discussions and issues:
Proposed Syntax:
Use
TablePartialto define reusable blocks and~<partial_name>to include them in tables.Example:
Design Considerations:
We explored various ways to achieve reusability. The chosen approach, using
TablePartialwith the~include syntax, functions like composition or mixins - the contents of the partial are effectively copied directly into the target table definition ("auto-inject").We opted for this composition model over implementing OOP-style table inheritance for several reasons:
We'd love your feedback on this proposal! Please share your thoughts below.
Thanks!
All reactions