Skip to content

Add new specialized Column subclass for system columns. #156

@giant0791

Description

@giant0791

Core system columns

Identity and container

Notion API Proposed Column Rationale
id object_id Avoid collision with user id columns
parent.database_id database_id Mirrors tableoid semantically

Lifecycle

Notion API Proposed Column Notes
in_trash is_deleted SQL-idiomatic
archived is_archived Keep as-is

Temporal metadata

Notion API Proposed Column
created_time created_at
last_edited_time updated_at

SystemColumn as specialized version of Column:

class Column(...):
    is_system: ClassVar[bool] = False

class SystemColumn(Column):
    is_system: ClassVar[bool] = True

Columns accessors new API

table.c                   # user-defined columns only
table.columns     # alias of table.c
table.sys               # system columns only
table.all                # optional convenience

Storage model:

class Table:
    _user_columns: ColumnCollection
    _system_columns: ColumnCollection

Implication on __len__

len(table) should return the number of user-defined columns only.
Add a new specialized function for returning schema size:

def schema_size(table: Table) -> int:
    return len(table.all)

Name collision and enforcement rules

System columns names are reserved

if name in system_column_names:
    raise SchemaError("Cannot redefine system column")

User cannot shadow system columns

This avoids:

Column("object_id", String)

Which would be catastrophic.

Metadata

Metadata

Assignees

Labels

Projects

Status

Todo

Relationships

None yet

Development

No branches or pull requests

Issue actions