Skip to content

pg

Postgres-specific column types.

NullBigInt = Null[int] module-attribute

A nullable big integer column. Alias for Null[int].

NullBoolean = Null[bool] module-attribute

A nullable boolean column. Alias for Null[bool].

NullDate = Null[date] module-attribute

A nullable date column. Alias for Null[date].

NullDoublePrecision = Null[float] module-attribute

A nullable double precision column. Alias for Null[float].

NullFloat = Null[float] module-attribute

A nullable float column. Alias for Null[float].

NullInteger = Null[int] module-attribute

A nullable integer column. Alias for Null[int].

NullInterval = Null[timedelta] module-attribute

A nullable interval column. Alias for Null[timedelta].

NullSmallInt = Null[int] module-attribute

A nullable small integer column. Alias for Null[int].

NullText = Null[str] module-attribute

A nullable text column. Alias for Null[str].

NullTimestamp = Null[datetime] module-attribute

A nullable timestamp column. Alias for Null[datetime].

NullVarchar = Null[str] module-attribute

A nullable varchar column. Alias for Null[str].

BigInt

Bases: Column[int]

Big integer column type.

Source code in src/embar/column/pg.py
133
134
135
136
137
138
139
class BigInt(Column[int]):
    """
    Big integer column type.
    """

    _sql_type: str = "BIGINT"
    _py_type: Type = int

BigSerial

Bases: Column[int]

Auto-incrementing big integer column.

Source code in src/embar/column/pg.py
152
153
154
155
156
157
158
class BigSerial(Column[int]):
    """
    Auto-incrementing big integer column.
    """

    _sql_type: str = "BIGSERIAL"
    _py_type: Type = int

Boolean

Bases: Column[bool]

Boolean column type.

Source code in src/embar/column/pg.py
 96
 97
 98
 99
100
101
102
class Boolean(Column[bool]):
    """
    Boolean column type.
    """

    _sql_type: str = "BOOLEAN"
    _py_type: Type = bool

Char

Bases: Column[str]

Fixed-length character column type.

Source code in src/embar/column/pg.py
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
class Char(Column[str]):
    """
    Fixed-length character column type.
    """

    _sql_type: str = "CHAR"
    _py_type: Type = str

    def __init__(
        self,
        name: str | None = None,
        default: str | _NoDefaultType = NO_DEFAULT,
        primary: bool = False,
        not_null: bool = False,
        length: int | None = None,
    ):
        """
        Create a new Char instance.
        """
        self._extra_args: tuple[int] | tuple[int, int] | None = (length,) if length is not None else None
        super().__init__(name=name, default=default, primary=primary, not_null=not_null)

__init__(name=None, default=NO_DEFAULT, primary=False, not_null=False, length=None)

Create a new Char instance.

Source code in src/embar/column/pg.py
193
194
195
196
197
198
199
200
201
202
203
204
205
def __init__(
    self,
    name: str | None = None,
    default: str | _NoDefaultType = NO_DEFAULT,
    primary: bool = False,
    not_null: bool = False,
    length: int | None = None,
):
    """
    Create a new Char instance.
    """
    self._extra_args: tuple[int] | tuple[int, int] | None = (length,) if length is not None else None
    super().__init__(name=name, default=default, primary=primary, not_null=not_null)

Date

Bases: Column[date]

Date column type.

Source code in src/embar/column/pg.py
303
304
305
306
307
308
309
class Date(Column[date]):
    """
    Date column type.
    """

    _sql_type: str = "DATE"
    _py_type: Type = date

DoublePrecision

Bases: Column[float]

Double precision floating point column type.

Source code in src/embar/column/pg.py
274
275
276
277
278
279
280
class DoublePrecision(Column[float]):
    """
    Double precision floating point column type.
    """

    _sql_type: str = "DOUBLE PRECISION"
    _py_type: Type = float

EmbarEnum

Bases: str, Enum

EmbarEnum is just a regular Enum but without having to set the right side.

from enum import auto
from embar.column.pg import EmbarEnum
class StatusEnum(EmbarEnum):
   PENDING = auto()
   DONE = auto()
Source code in src/embar/column/pg.py
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
class EmbarEnum(str, Enum):
    """
    `EmbarEnum` is just a regular Enum but without having to set the right side.

    ```python
    from enum import auto
    from embar.column.pg import EmbarEnum
    class StatusEnum(EmbarEnum):
       PENDING = auto()
       DONE = auto()
    ```
    """

    @staticmethod
    @override
    def _generate_next_value_(name: str, start: int, count: int, last_values: list[Any]) -> str:
        return name

EnumCol

Bases: Column[str]

Column type for Postgres enum values.

Source code in src/embar/column/pg.py
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
class EnumCol[E: EmbarEnum](Column[str]):
    """
    Column type for Postgres enum values.
    """

    _sql_type: str
    _py_type: Type = str

    def __init__(
        self,
        pg_enum: type[PgEnum[E]],
        name: str | None = None,
        default: E | _NoDefaultType = NO_DEFAULT,
        primary: bool = False,
        not_null: bool = False,
    ):
        """
        Create a new EnumCol instance.
        """
        self._sql_type = pg_enum.name

        super().__init__(name=name, default=default, primary=primary, not_null=not_null)

__init__(pg_enum, name=None, default=NO_DEFAULT, primary=False, not_null=False)

Create a new EnumCol instance.

Source code in src/embar/column/pg.py
382
383
384
385
386
387
388
389
390
391
392
393
394
395
def __init__(
    self,
    pg_enum: type[PgEnum[E]],
    name: str | None = None,
    default: E | _NoDefaultType = NO_DEFAULT,
    primary: bool = False,
    not_null: bool = False,
):
    """
    Create a new EnumCol instance.
    """
    self._sql_type = pg_enum.name

    super().__init__(name=name, default=default, primary=primary, not_null=not_null)

Float

Bases: Column[float]

A floating point column type.

Source code in src/embar/column/common.py
159
160
161
162
163
164
165
class Float(Column[float]):
    """
    A floating point column type.
    """

    _sql_type: str = "REAL"
    _py_type: Type = float

Integer

Bases: Column[int]

An integer column type.

Source code in src/embar/column/common.py
150
151
152
153
154
155
156
class Integer(Column[int]):
    """
    An integer column type.
    """

    _sql_type: str = "INTEGER"
    _py_type: Type = int

Interval

Bases: Column[timedelta]

Interval column type for storing time intervals.

Source code in src/embar/column/pg.py
312
313
314
315
316
317
318
class Interval(Column[timedelta]):
    """
    Interval column type for storing time intervals.
    """

    _sql_type: str = "INTERVAL"
    _py_type: Type = timedelta

Json

Bases: Column[dict[str, Any]]

JSON column type for storing JSON data.

Source code in src/embar/column/pg.py
284
285
286
287
288
289
290
class Json(Column[dict[str, Any]]):
    """
    JSON column type for storing JSON data.
    """

    _sql_type: str = "JSON"
    _py_type: Type = dict[str, Any]

Jsonb

Bases: Column[dict[str, Any]]

JSONB column type for storing JSON data.

Source code in src/embar/column/pg.py
114
115
116
117
118
119
120
class Jsonb(Column[dict[str, Any]]):
    """
    JSONB column type for storing JSON data.
    """

    _sql_type: str = "JSONB"
    _py_type: Type = dict[str, Any]

Null

Bases: Column[T | None]

A nullable column type.

Use this as the annotation for columns that can be NULL in the database. The type parameter T is the underlying Python type (e.g. str, int).

At the class level, Null[str] is a :class:ColumnBase so it works in order_by, where, Annotated, etc. At the instance level, the value is typed as T | None.

Convenience aliases are provided: :data:NullText, :data:NullInteger, :data:NullFloat.

from embar.table import Table
from embar.column.common import Text, NullText, text, integer, NullInteger
class MyTable(Table):
    name: Text = text()
    email: NullText = text(default=None)      # nullable, optional
    age: NullInteger = integer(default=None)   # nullable, optional
row = MyTable(name="foo")
assert row.email is None
Source code in src/embar/column/common.py
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
class Null[T: PyType](Column[T | None]):
    """
    A nullable column type.

    Use this as the annotation for columns that can be ``NULL`` in the database.
    The type parameter ``T`` is the underlying Python type (e.g. ``str``, ``int``).

    At the class level, ``Null[str]`` is a :class:`ColumnBase` so it works in
    ``order_by``, ``where``, ``Annotated``, etc.  At the instance level, the
    value is typed as ``T | None``.

    Convenience aliases are provided: :data:`NullText`, :data:`NullInteger`,
    :data:`NullFloat`.

    ```python
    from embar.table import Table
    from embar.column.common import Text, NullText, text, integer, NullInteger
    class MyTable(Table):
        name: Text = text()
        email: NullText = text(default=None)      # nullable, optional
        age: NullInteger = integer(default=None)   # nullable, optional
    row = MyTable(name="foo")
    assert row.email is None
    ```
    """

    def __init__(
        self,
        sql_type: str,
        py_type: Type,
        name: str | None = None,
        default: T | None | _NoDefaultType = NO_DEFAULT,
        primary: bool = False,
        not_null: bool = False,
    ):
        self._sql_type = sql_type
        self._py_type = py_type
        super().__init__(name=name, default=default, primary=primary, not_null=not_null)

Numeric

Bases: Column[Decimal]

Numeric column type with configurable precision and scale.

Source code in src/embar/column/pg.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
class Numeric(Column[Decimal]):
    """
    Numeric column type with configurable precision and scale.
    """

    _sql_type: str = "NUMERIC"
    _py_type: Type = Decimal

    _extra_args: tuple[int] | tuple[int, int] | None

    def __init__(
        self,
        name: str | None = None,
        default: Decimal | _NoDefaultType = NO_DEFAULT,
        primary: bool = False,
        not_null: bool = False,
        precision: int | None = None,
        scale: int | None = None,
    ):
        """
        Create a new Numeric instance.
        """
        if precision is None:
            if scale is not None:
                raise Exception("Numeric: 'precision' cannot be None if scale is set")
        elif scale is None:
            self._extra_args = (precision,)
        else:
            self._extra_args = (precision, scale)
        super().__init__(name=name, default=default, primary=primary, not_null=not_null)

__init__(name=None, default=NO_DEFAULT, primary=False, not_null=False, precision=None, scale=None)

Create a new Numeric instance.

Source code in src/embar/column/pg.py
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
def __init__(
    self,
    name: str | None = None,
    default: Decimal | _NoDefaultType = NO_DEFAULT,
    primary: bool = False,
    not_null: bool = False,
    precision: int | None = None,
    scale: int | None = None,
):
    """
    Create a new Numeric instance.
    """
    if precision is None:
        if scale is not None:
            raise Exception("Numeric: 'precision' cannot be None if scale is set")
    elif scale is None:
        self._extra_args = (precision,)
    else:
        self._extra_args = (precision, scale)
    super().__init__(name=name, default=default, primary=primary, not_null=not_null)

PgDecimal

Bases: Column[Decimal]

Decimal column type with configurable precision and scale.

Source code in src/embar/column/pg.py
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
class PgDecimal(Column[Decimal]):
    """
    Decimal column type with configurable precision and scale.
    """

    # Note: DECIMAL is an alias for NUMERIC in PostgreSQL
    _sql_type: str = "DECIMAL"
    _py_type: Type = Decimal

    _extra_args: tuple[int] | tuple[int, int] | None

    def __init__(
        self,
        name: str | None = None,
        default: Decimal | _NoDefaultType = NO_DEFAULT,
        primary: bool = False,
        not_null: bool = False,
        precision: int | None = None,
        scale: int | None = None,
    ):
        """
        Create a new PgDecimal instance.
        """
        if precision is None:
            if scale is not None:
                raise Exception("Numeric: 'precision' cannot be None if scale is set")
        elif scale is None:
            self._extra_args = (precision,)
        else:
            self._extra_args = (precision, scale)
        super().__init__(name=name, default=default, primary=primary, not_null=not_null)

__init__(name=None, default=NO_DEFAULT, primary=False, not_null=False, precision=None, scale=None)

Create a new PgDecimal instance.

Source code in src/embar/column/pg.py
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
def __init__(
    self,
    name: str | None = None,
    default: Decimal | _NoDefaultType = NO_DEFAULT,
    primary: bool = False,
    not_null: bool = False,
    precision: int | None = None,
    scale: int | None = None,
):
    """
    Create a new PgDecimal instance.
    """
    if precision is None:
        if scale is not None:
            raise Exception("Numeric: 'precision' cannot be None if scale is set")
    elif scale is None:
        self._extra_args = (precision,)
    else:
        self._extra_args = (precision, scale)
    super().__init__(name=name, default=default, primary=primary, not_null=not_null)

PgEnum

Bases: EnumBase

`PgEnum is used to create Postgres enum types.

Subclasses must always assign values to the two class variables!

from enum import auto
from embar.table import Table
from embar.column.pg import EmbarEnum, EnumCol, PgEnum, enum_col
class StatusEnum(EmbarEnum):
   PENDING = auto()
   DONE = auto()
class StatusPgEnum(PgEnum[StatusEnum]):
    name: str = "status_enum"
    enum: type[StatusEnum] = StatusEnum
class TableWithStatus(Table):
    status: EnumCol[StatusEnum] = enum_col(StatusPgEnum)
Source code in src/embar/column/pg.py
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
class PgEnum[E: EmbarEnum](EnumBase):
    """
    `PgEnum is used to create Postgres enum types.

    Subclasses must always assign values to the two class variables!

    ```python
    from enum import auto
    from embar.table import Table
    from embar.column.pg import EmbarEnum, EnumCol, PgEnum, enum_col
    class StatusEnum(EmbarEnum):
       PENDING = auto()
       DONE = auto()
    class StatusPgEnum(PgEnum[StatusEnum]):
        name: str = "status_enum"
        enum: type[StatusEnum] = StatusEnum
    class TableWithStatus(Table):
        status: EnumCol[StatusEnum] = enum_col(StatusPgEnum)
    ```
    """

    name: str
    enum: type[E]

    @override
    @classmethod
    def ddl(cls) -> str:
        quoted = [f"'{e.name}'" for e in cls.enum]
        values = ", ".join(quoted)
        sql = f"CREATE TYPE {cls.name} AS ENUM ({values});"
        return sql

Serial

Bases: Column[int]

Auto-incrementing integer column.

Source code in src/embar/column/pg.py
87
88
89
90
91
92
93
class Serial(Column[int]):
    """
    Auto-incrementing integer column.
    """

    _sql_type: str = "SERIAL"
    _py_type: Type = int

SmallInt

Bases: Column[int]

Small integer column type.

Source code in src/embar/column/pg.py
124
125
126
127
128
129
130
class SmallInt(Column[int]):
    """
    Small integer column type.
    """

    _sql_type: str = "SMALLINT"
    _py_type: Type = int

SmallSerial

Bases: Column[int]

Auto-incrementing small integer column.

Source code in src/embar/column/pg.py
143
144
145
146
147
148
149
class SmallSerial(Column[int]):
    """
    Auto-incrementing small integer column.
    """

    _sql_type: str = "SMALLSERIAL"
    _py_type: Type = int

Text

Bases: Column[str]

A text column type.

Source code in src/embar/column/common.py
141
142
143
144
145
146
147
class Text(Column[str]):
    """
    A text column type.
    """

    _sql_type: str = "TEXT"
    _py_type: Type = str

Time

Bases: Column[time]

Time column type.

Source code in src/embar/column/pg.py
294
295
296
297
298
299
300
class Time(Column[time]):
    """
    Time column type.
    """

    _sql_type: str = "TIME"
    _py_type: Type = time

Timestamp

Bases: Column[datetime]

Timestamp column type.

Source code in src/embar/column/pg.py
105
106
107
108
109
110
111
class Timestamp(Column[datetime]):
    """
    Timestamp column type.
    """

    _sql_type: str = "TIMESTAMP"
    _py_type: Type = str

Varchar

Bases: Column[str]

Variable-length character column type.

Source code in src/embar/column/pg.py
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
class Varchar(Column[str]):
    """
    Variable-length character column type.
    """

    _sql_type: str = "VARCHAR"
    _py_type: Type = str

    def __init__(
        self,
        name: str | None = None,
        default: str | _NoDefaultType = NO_DEFAULT,
        primary: bool = False,
        not_null: bool = False,
        length: int | None = None,
    ):
        """
        Create a new Varchar instance.
        """
        self._extra_args: tuple[int] | tuple[int, int] | None = (length,) if length is not None else None
        super().__init__(name=name, default=default, primary=primary, not_null=not_null)

__init__(name=None, default=NO_DEFAULT, primary=False, not_null=False, length=None)

Create a new Varchar instance.

Source code in src/embar/column/pg.py
170
171
172
173
174
175
176
177
178
179
180
181
182
def __init__(
    self,
    name: str | None = None,
    default: str | _NoDefaultType = NO_DEFAULT,
    primary: bool = False,
    not_null: bool = False,
    length: int | None = None,
):
    """
    Create a new Varchar instance.
    """
    self._extra_args: tuple[int] | tuple[int, int] | None = (length,) if length is not None else None
    super().__init__(name=name, default=default, primary=primary, not_null=not_null)

Vector

Bases: Column[list[float]]

Vector column using pgvector.

This assumes the extension is already installed and activated with CREATE EXTENSION vector;

Source code in src/embar/column/pg.py
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
class Vector(Column[list[float]]):
    """
    Vector column using [pgvector](https://github.com/pgvector/pgvector).

    This assumes the extension is already installed and activated with
    CREATE EXTENSION vector;
    """

    _sql_type: str = "VECTOR"
    _py_type: Type = list[float]

    def __init__(
        self,
        length: int,
        name: str | None = None,
        default: list[float] | _NoDefaultType = NO_DEFAULT,
        primary: bool = False,
        not_null: bool = False,
    ):
        """
        Create a new Vector instance.
        """
        self._extra_args: tuple[int] | tuple[int, int] | None = (length,)
        super().__init__(name=name, default=default, primary=primary, not_null=not_null)

__init__(length, name=None, default=NO_DEFAULT, primary=False, not_null=False)

Create a new Vector instance.

Source code in src/embar/column/pg.py
411
412
413
414
415
416
417
418
419
420
421
422
423
def __init__(
    self,
    length: int,
    name: str | None = None,
    default: list[float] | _NoDefaultType = NO_DEFAULT,
    primary: bool = False,
    not_null: bool = False,
):
    """
    Create a new Vector instance.
    """
    self._extra_args: tuple[int] | tuple[int, int] | None = (length,)
    super().__init__(name=name, default=default, primary=primary, not_null=not_null)

bigint(name=None, *, default=NO_DEFAULT, primary=False, not_null=False, fk=None, on_delete=None)

bigint(
    name: str | None = ...,
    *,
    primary: bool = ...,
    not_null: bool = ...,
    fk: Callable[[], Column[int]] | None = ...,
    on_delete: OnDelete | None = ...,
) -> BigInt
bigint(
    name: str | None = ...,
    *,
    default: int,
    primary: bool = ...,
    not_null: bool = ...,
    fk: Callable[[], Column[int]] | None = ...,
    on_delete: OnDelete | None = ...,
) -> BigInt
bigint(
    name: str | None = ...,
    *,
    default: None,
    primary: bool = ...,
    not_null: bool = ...,
    fk: Callable[[], Column[int]] | None = ...,
    on_delete: OnDelete | None = ...,
) -> NullBigInt

Create a :class:BigInt column.

Source code in src/embar/column/pg.py
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
def bigint(
    name: str | None = None,
    *,
    default: int | None | _NoDefaultType = NO_DEFAULT,
    primary: bool = False,
    not_null: bool = False,
    fk: Callable[[], Column[int]] | None = None,
    on_delete: OnDelete | None = None,
) -> BigInt | NullBigInt:
    """Create a :class:`BigInt` column."""
    col: BigInt | Null[int]
    if default is None:
        col = Null[int](sql_type="BIGINT", py_type=int, name=name, default=default, primary=primary, not_null=not_null)
    else:
        col = BigInt(name=name, default=default, primary=primary, not_null=not_null)
    if fk is not None:
        col.fk(fk, on_delete)
    return col

bigserial(name=None, *, default=NO_DEFAULT, primary=False, not_null=False)

bigserial(
    name: str | None = ...,
    *,
    primary: bool = ...,
    not_null: bool = ...,
) -> BigSerial
bigserial(
    name: str | None = ...,
    *,
    default: int,
    primary: bool = ...,
    not_null: bool = ...,
) -> BigSerial
bigserial(
    name: str | None = ...,
    *,
    default: None,
    primary: bool = ...,
    not_null: bool = ...,
) -> Null[int]

Create a :class:BigSerial column.

Source code in src/embar/column/pg.py
837
838
839
840
841
842
843
844
845
846
847
848
849
def bigserial(
    name: str | None = None,
    *,
    default: int | None | _NoDefaultType = NO_DEFAULT,
    primary: bool = False,
    not_null: bool = False,
) -> BigSerial | Null[int]:
    """Create a :class:`BigSerial` column."""
    if default is None:
        return Null[int](
            sql_type="BIGSERIAL", py_type=int, name=name, default=default, primary=primary, not_null=not_null
        )
    return BigSerial(name=name, default=default, primary=primary, not_null=not_null)

boolean(name=None, *, default=NO_DEFAULT, primary=False, not_null=False)

boolean(
    name: str | None = ...,
    *,
    primary: bool = ...,
    not_null: bool = ...,
) -> Boolean
boolean(
    name: str | None = ...,
    *,
    default: bool,
    primary: bool = ...,
    not_null: bool = ...,
) -> Boolean
boolean(
    name: str | None = ...,
    *,
    default: None,
    primary: bool = ...,
    not_null: bool = ...,
) -> NullBoolean

Create a :class:Boolean column.

Source code in src/embar/column/pg.py
549
550
551
552
553
554
555
556
557
558
559
560
561
def boolean(
    name: str | None = None,
    *,
    default: bool | None | _NoDefaultType = NO_DEFAULT,
    primary: bool = False,
    not_null: bool = False,
) -> Boolean | NullBoolean:
    """Create a :class:`Boolean` column."""
    if default is None:
        return Null[bool](
            sql_type="BOOLEAN", py_type=bool, name=name, default=default, primary=primary, not_null=not_null
        )
    return Boolean(name=name, default=default, primary=primary, not_null=not_null)

char_col(name=None, *, default=NO_DEFAULT, primary=False, not_null=False, length=None, fk=None, on_delete=None)

char_col(
    name: str | None = ...,
    *,
    primary: bool = ...,
    not_null: bool = ...,
    length: int | None = ...,
    fk: Callable[[], Column[str]] | None = ...,
    on_delete: OnDelete | None = ...,
) -> Char
char_col(
    name: str | None = ...,
    *,
    default: str,
    primary: bool = ...,
    not_null: bool = ...,
    length: int | None = ...,
    fk: Callable[[], Column[str]] | None = ...,
    on_delete: OnDelete | None = ...,
) -> Char
char_col(
    name: str | None = ...,
    *,
    default: None,
    primary: bool = ...,
    not_null: bool = ...,
    length: int | None = ...,
    fk: Callable[[], Column[str]] | None = ...,
    on_delete: OnDelete | None = ...,
) -> Null[str]

Create a :class:Char column.

Source code in src/embar/column/pg.py
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
def char_col(
    name: str | None = None,
    *,
    default: str | None | _NoDefaultType = NO_DEFAULT,
    primary: bool = False,
    not_null: bool = False,
    length: int | None = None,
    fk: Callable[[], Column[str]] | None = None,
    on_delete: OnDelete | None = None,
) -> Char | Null[str]:
    """Create a :class:`Char` column."""
    col: Char | Null[str]
    if default is None:
        col = Null[str](sql_type="CHAR", py_type=str, name=name, default=default, primary=primary, not_null=not_null)
        if length is not None:
            col._extra_args = (length,)
    else:
        col = Char(name=name, default=default, primary=primary, not_null=not_null, length=length)
    if fk is not None:
        col.fk(fk, on_delete)
    return col

date_col(name=None, *, default=NO_DEFAULT, primary=False, not_null=False)

date_col(
    name: str | None = ...,
    *,
    primary: bool = ...,
    not_null: bool = ...,
) -> Date
date_col(
    name: str | None = ...,
    *,
    default: date,
    primary: bool = ...,
    not_null: bool = ...,
) -> Date
date_col(
    name: str | None = ...,
    *,
    default: None,
    primary: bool = ...,
    not_null: bool = ...,
) -> NullDate

Create a :class:Date column.

Source code in src/embar/column/pg.py
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
def date_col(
    name: str | None = None,
    *,
    default: date | None | _NoDefaultType = NO_DEFAULT,
    primary: bool = False,
    not_null: bool = False,
) -> Date | NullDate:
    """Create a :class:`Date` column."""
    if default is None:
        return Null[date](sql_type="DATE", py_type=date, name=name, default=default, primary=primary, not_null=not_null)
    return Date(name=name, default=default, primary=primary, not_null=not_null)

double_precision(name=None, *, default=NO_DEFAULT, primary=False, not_null=False)

double_precision(
    name: str | None = ...,
    *,
    primary: bool = ...,
    not_null: bool = ...,
) -> DoublePrecision
double_precision(
    name: str | None = ...,
    *,
    default: float,
    primary: bool = ...,
    not_null: bool = ...,
) -> DoublePrecision
double_precision(
    name: str | None = ...,
    *,
    default: None,
    primary: bool = ...,
    not_null: bool = ...,
) -> NullDoublePrecision

Create a :class:DoublePrecision column.

Source code in src/embar/column/pg.py
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
def double_precision(
    name: str | None = None,
    *,
    default: float | None | _NoDefaultType = NO_DEFAULT,
    primary: bool = False,
    not_null: bool = False,
) -> DoublePrecision | NullDoublePrecision:
    """Create a :class:`DoublePrecision` column."""
    if default is None:
        return Null[float](
            sql_type="DOUBLE PRECISION", py_type=float, name=name, default=default, primary=primary, not_null=not_null
        )
    return DoublePrecision(name=name, default=default, primary=primary, not_null=not_null)

enum_col(pg_enum, name=None, default=NO_DEFAULT, *, primary=False, not_null=False)

Create an :class:EnumCol column.

Source code in src/embar/column/pg.py
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
def enum_col[E: EmbarEnum](
    pg_enum: type[PgEnum[E]],
    name: str | None = None,
    default: E | _NoDefaultType = NO_DEFAULT,
    *,
    primary: bool = False,
    not_null: bool = False,
) -> EnumCol[E]:
    """Create an :class:`EnumCol` column."""
    return EnumCol(pg_enum, name=name, default=default, primary=primary, not_null=not_null)

float_col(name=None, *, default=NO_DEFAULT, primary=False, not_null=False, fk=None, on_delete=None)

float_col(
    name: str | None = ...,
    *,
    primary: bool = ...,
    not_null: bool = ...,
    fk: Callable[[], Column[float]] | None = ...,
    on_delete: OnDelete | None = ...,
) -> Float
float_col(
    name: str | None = ...,
    *,
    default: float,
    primary: bool = ...,
    not_null: bool = ...,
    fk: Callable[[], Column[float]] | None = ...,
    on_delete: OnDelete | None = ...,
) -> Float
float_col(
    name: str | None = ...,
    *,
    default: None,
    primary: bool = ...,
    not_null: bool = ...,
    fk: Callable[[], Column[float]] | None = ...,
    on_delete: OnDelete | None = ...,
) -> NullFloat

Create a :class:Float column (field specifier for @dataclass_transform).

Source code in src/embar/column/common.py
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
def float_col(
    name: str | None = None,
    *,
    default: float | None | _NoDefaultType = NO_DEFAULT,
    primary: bool = False,
    not_null: bool = False,
    fk: Callable[[], Column[float]] | None = None,
    on_delete: OnDelete | None = None,
) -> Float | NullFloat:
    """Create a :class:`Float` column (field specifier for ``@dataclass_transform``)."""
    col: Float | Null[float]
    if default is None:
        col = Null[float](
            sql_type="REAL", py_type=float, name=name, default=default, primary=primary, not_null=not_null
        )
    else:
        col = Float(name=name, default=default, primary=primary, not_null=not_null)
    if fk is not None:
        col.fk(fk, on_delete)
    return col

integer(name=None, *, default=NO_DEFAULT, primary=False, not_null=False, fk=None, on_delete=None)

integer(
    name: str | None = ...,
    *,
    primary: bool = ...,
    not_null: bool = ...,
    fk: Callable[[], Column[int]] | None = ...,
    on_delete: OnDelete | None = ...,
) -> Integer
integer(
    name: str | None = ...,
    *,
    default: int,
    primary: bool = ...,
    not_null: bool = ...,
    fk: Callable[[], Column[int]] | None = ...,
    on_delete: OnDelete | None = ...,
) -> Integer
integer(
    name: str | None = ...,
    *,
    default: None,
    primary: bool = ...,
    not_null: bool = ...,
    fk: Callable[[], Column[int]] | None = ...,
    on_delete: OnDelete | None = ...,
) -> NullInteger

Create an :class:Integer column (field specifier for @dataclass_transform).

Source code in src/embar/column/common.py
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
def integer(
    name: str | None = None,
    *,
    default: int | None | _NoDefaultType = NO_DEFAULT,
    primary: bool = False,
    not_null: bool = False,
    fk: Callable[[], Column[int]] | None = None,
    on_delete: OnDelete | None = None,
) -> Integer | NullInteger:
    """Create an :class:`Integer` column (field specifier for ``@dataclass_transform``)."""
    col: Integer | Null[int]
    if default is None:
        col = Null[int](sql_type="INTEGER", py_type=int, name=name, default=default, primary=primary, not_null=not_null)
    else:
        col = Integer(name=name, default=default, primary=primary, not_null=not_null)
    if fk is not None:
        col.fk(fk, on_delete)
    return col

interval(name=None, *, default=NO_DEFAULT, primary=False, not_null=False)

interval(
    name: str | None = ...,
    *,
    primary: bool = ...,
    not_null: bool = ...,
) -> Interval
interval(
    name: str | None = ...,
    *,
    default: timedelta,
    primary: bool = ...,
    not_null: bool = ...,
) -> Interval
interval(
    name: str | None = ...,
    *,
    default: None,
    primary: bool = ...,
    not_null: bool = ...,
) -> NullInterval

Create an :class:Interval column.

Source code in src/embar/column/pg.py
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
def interval(
    name: str | None = None,
    *,
    default: timedelta | None | _NoDefaultType = NO_DEFAULT,
    primary: bool = False,
    not_null: bool = False,
) -> Interval | NullInterval:
    """Create an :class:`Interval` column."""
    if default is None:
        return Null[timedelta](
            sql_type="INTERVAL", py_type=timedelta, name=name, default=default, primary=primary, not_null=not_null
        )
    return Interval(name=name, default=default, primary=primary, not_null=not_null)

json_col(name=None, *, default=NO_DEFAULT, primary=False, not_null=False)

json_col(
    name: str | None = ...,
    *,
    primary: bool = ...,
    not_null: bool = ...,
) -> Json
json_col(
    name: str | None = ...,
    *,
    default: dict[str, Any],
    primary: bool = ...,
    not_null: bool = ...,
) -> Json
json_col(
    name: str | None = ...,
    *,
    default: None,
    primary: bool = ...,
    not_null: bool = ...,
) -> Null[dict[str, Any]]

Create a :class:Json column.

Source code in src/embar/column/pg.py
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
def json_col(
    name: str | None = None,
    *,
    default: dict[str, Any] | None | _NoDefaultType = NO_DEFAULT,
    primary: bool = False,
    not_null: bool = False,
) -> Json | Null[dict[str, Any]]:
    """Create a :class:`Json` column."""
    if default is None:
        return Null[dict[str, Any]](
            sql_type="JSON", py_type=dict, name=name, default=default, primary=primary, not_null=not_null
        )
    return Json(name=name, default=default, primary=primary, not_null=not_null)

jsonb(name=None, *, default=NO_DEFAULT, primary=False, not_null=False)

jsonb(
    name: str | None = ...,
    *,
    primary: bool = ...,
    not_null: bool = ...,
) -> Jsonb
jsonb(
    name: str | None = ...,
    *,
    default: dict[str, Any],
    primary: bool = ...,
    not_null: bool = ...,
) -> Jsonb
jsonb(
    name: str | None = ...,
    *,
    default: None,
    primary: bool = ...,
    not_null: bool = ...,
) -> Null[dict[str, Any]]

Create a :class:Jsonb column.

Source code in src/embar/column/pg.py
637
638
639
640
641
642
643
644
645
646
647
648
649
def jsonb(
    name: str | None = None,
    *,
    default: dict[str, Any] | None | _NoDefaultType = NO_DEFAULT,
    primary: bool = False,
    not_null: bool = False,
) -> Jsonb | Null[dict[str, Any]]:
    """Create a :class:`Jsonb` column."""
    if default is None:
        return Null[dict[str, Any]](
            sql_type="JSONB", py_type=dict, name=name, default=default, primary=primary, not_null=not_null
        )
    return Jsonb(name=name, default=default, primary=primary, not_null=not_null)

numeric(name=None, *, default=NO_DEFAULT, primary=False, not_null=False, precision=None, scale=None)

numeric(
    name: str | None = ...,
    *,
    primary: bool = ...,
    not_null: bool = ...,
    precision: int | None = ...,
    scale: int | None = ...,
) -> Numeric
numeric(
    name: str | None = ...,
    *,
    default: Decimal,
    primary: bool = ...,
    not_null: bool = ...,
    precision: int | None = ...,
    scale: int | None = ...,
) -> Numeric
numeric(
    name: str | None = ...,
    *,
    default: None,
    primary: bool = ...,
    not_null: bool = ...,
    precision: int | None = ...,
    scale: int | None = ...,
) -> Null[Decimal]

Create a :class:Numeric column.

Source code in src/embar/column/pg.py
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
def numeric(
    name: str | None = None,
    *,
    default: Decimal | None | _NoDefaultType = NO_DEFAULT,
    primary: bool = False,
    not_null: bool = False,
    precision: int | None = None,
    scale: int | None = None,
) -> Numeric | Null[Decimal]:
    """Create a :class:`Numeric` column."""
    if default is None:
        col: Null[Decimal] = Null[Decimal](
            sql_type="NUMERIC", py_type=Decimal, name=name, default=default, primary=primary, not_null=not_null
        )
        if precision is not None:
            if scale is not None:
                col._extra_args = (precision, scale)
            else:
                col._extra_args = (precision,)
        return col
    return Numeric(name=name, default=default, primary=primary, not_null=not_null, precision=precision, scale=scale)

pg_decimal(name=None, *, default=NO_DEFAULT, primary=False, not_null=False, precision=None, scale=None)

pg_decimal(
    name: str | None = ...,
    *,
    primary: bool = ...,
    not_null: bool = ...,
    precision: int | None = ...,
    scale: int | None = ...,
) -> PgDecimal
pg_decimal(
    name: str | None = ...,
    *,
    default: Decimal,
    primary: bool = ...,
    not_null: bool = ...,
    precision: int | None = ...,
    scale: int | None = ...,
) -> PgDecimal
pg_decimal(
    name: str | None = ...,
    *,
    default: None,
    primary: bool = ...,
    not_null: bool = ...,
    precision: int | None = ...,
    scale: int | None = ...,
) -> Null[Decimal]

Create a :class:PgDecimal column.

Source code in src/embar/column/pg.py
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
def pg_decimal(
    name: str | None = None,
    *,
    default: Decimal | None | _NoDefaultType = NO_DEFAULT,
    primary: bool = False,
    not_null: bool = False,
    precision: int | None = None,
    scale: int | None = None,
) -> PgDecimal | Null[Decimal]:
    """Create a :class:`PgDecimal` column."""
    if default is None:
        col: Null[Decimal] = Null[Decimal](
            sql_type="DECIMAL", py_type=Decimal, name=name, default=default, primary=primary, not_null=not_null
        )
        if precision is not None:
            if scale is not None:
                col._extra_args = (precision, scale)
            else:
                col._extra_args = (precision,)
        return col
    return PgDecimal(name=name, default=default, primary=primary, not_null=not_null, precision=precision, scale=scale)

serial(name=None, *, default=NO_DEFAULT, primary=False, not_null=False, fk=None, on_delete=None)

serial(
    name: str | None = ...,
    *,
    primary: bool = ...,
    not_null: bool = ...,
    fk: Callable[[], Column[int]] | None = ...,
    on_delete: OnDelete | None = ...,
) -> Serial
serial(
    name: str | None = ...,
    *,
    default: int,
    primary: bool = ...,
    not_null: bool = ...,
    fk: Callable[[], Column[int]] | None = ...,
    on_delete: OnDelete | None = ...,
) -> Serial
serial(
    name: str | None = ...,
    *,
    default: None,
    primary: bool = ...,
    not_null: bool = ...,
    fk: Callable[[], Column[int]] | None = ...,
    on_delete: OnDelete | None = ...,
) -> Null[int]

Create a :class:Serial column.

Source code in src/embar/column/pg.py
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
def serial(
    name: str | None = None,
    *,
    default: int | None | _NoDefaultType = NO_DEFAULT,
    primary: bool = False,
    not_null: bool = False,
    fk: Callable[[], Column[int]] | None = None,
    on_delete: OnDelete | None = None,
) -> Serial | Null[int]:
    """Create a :class:`Serial` column."""
    col: Serial | Null[int]
    if default is None:
        col = Null[int](sql_type="SERIAL", py_type=int, name=name, default=default, primary=primary, not_null=not_null)
    else:
        col = Serial(name=name, default=default, primary=primary, not_null=not_null)
    if fk is not None:
        col.fk(fk, on_delete)
    return col

smallint(name=None, *, default=NO_DEFAULT, primary=False, not_null=False, fk=None, on_delete=None)

smallint(
    name: str | None = ...,
    *,
    primary: bool = ...,
    not_null: bool = ...,
    fk: Callable[[], Column[int]] | None = ...,
    on_delete: OnDelete | None = ...,
) -> SmallInt
smallint(
    name: str | None = ...,
    *,
    default: int,
    primary: bool = ...,
    not_null: bool = ...,
    fk: Callable[[], Column[int]] | None = ...,
    on_delete: OnDelete | None = ...,
) -> SmallInt
smallint(
    name: str | None = ...,
    *,
    default: None,
    primary: bool = ...,
    not_null: bool = ...,
    fk: Callable[[], Column[int]] | None = ...,
    on_delete: OnDelete | None = ...,
) -> NullSmallInt

Create a :class:SmallInt column.

Source code in src/embar/column/pg.py
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
def smallint(
    name: str | None = None,
    *,
    default: int | None | _NoDefaultType = NO_DEFAULT,
    primary: bool = False,
    not_null: bool = False,
    fk: Callable[[], Column[int]] | None = None,
    on_delete: OnDelete | None = None,
) -> SmallInt | NullSmallInt:
    """Create a :class:`SmallInt` column."""
    col: SmallInt | Null[int]
    if default is None:
        col = Null[int](
            sql_type="SMALLINT", py_type=int, name=name, default=default, primary=primary, not_null=not_null
        )
    else:
        col = SmallInt(name=name, default=default, primary=primary, not_null=not_null)
    if fk is not None:
        col.fk(fk, on_delete)
    return col

smallserial(name=None, *, default=NO_DEFAULT, primary=False, not_null=False)

smallserial(
    name: str | None = ...,
    *,
    primary: bool = ...,
    not_null: bool = ...,
) -> SmallSerial
smallserial(
    name: str | None = ...,
    *,
    default: int,
    primary: bool = ...,
    not_null: bool = ...,
) -> SmallSerial
smallserial(
    name: str | None = ...,
    *,
    default: None,
    primary: bool = ...,
    not_null: bool = ...,
) -> Null[int]

Create a :class:SmallSerial column.

Source code in src/embar/column/pg.py
793
794
795
796
797
798
799
800
801
802
803
804
805
def smallserial(
    name: str | None = None,
    *,
    default: int | None | _NoDefaultType = NO_DEFAULT,
    primary: bool = False,
    not_null: bool = False,
) -> SmallSerial | Null[int]:
    """Create a :class:`SmallSerial` column."""
    if default is None:
        return Null[int](
            sql_type="SMALLSERIAL", py_type=int, name=name, default=default, primary=primary, not_null=not_null
        )
    return SmallSerial(name=name, default=default, primary=primary, not_null=not_null)

text(name=None, *, default=NO_DEFAULT, primary=False, not_null=False, fk=None, on_delete=None)

text(
    name: str | None = ...,
    *,
    primary: bool = ...,
    not_null: bool = ...,
    fk: Callable[[], Column[str]] | None = ...,
    on_delete: OnDelete | None = ...,
) -> Text
text(
    name: str | None = ...,
    *,
    default: str,
    primary: bool = ...,
    not_null: bool = ...,
    fk: Callable[[], Column[str]] | None = ...,
    on_delete: OnDelete | None = ...,
) -> Text
text(
    name: str | None = ...,
    *,
    default: None,
    primary: bool = ...,
    not_null: bool = ...,
    fk: Callable[[], Column[str]] | None = ...,
    on_delete: OnDelete | None = ...,
) -> NullText

Create a :class:Text column (field specifier for @dataclass_transform).

Source code in src/embar/column/common.py
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
def text(
    name: str | None = None,
    *,
    default: str | None | _NoDefaultType = NO_DEFAULT,
    primary: bool = False,
    not_null: bool = False,
    fk: Callable[[], Column[str]] | None = None,
    on_delete: OnDelete | None = None,
) -> Text | NullText:
    """Create a :class:`Text` column (field specifier for ``@dataclass_transform``)."""
    col: Text | Null[str]
    if default is None:
        col = Null[str](sql_type="TEXT", py_type=str, name=name, default=default, primary=primary, not_null=not_null)
    else:
        col = Text(name=name, default=default, primary=primary, not_null=not_null)
    if fk is not None:
        col.fk(fk, on_delete)
    return col

time_col(name=None, *, default=NO_DEFAULT, primary=False, not_null=False)

time_col(
    name: str | None = ...,
    *,
    primary: bool = ...,
    not_null: bool = ...,
) -> Time
time_col(
    name: str | None = ...,
    *,
    default: time,
    primary: bool = ...,
    not_null: bool = ...,
) -> Time
time_col(
    name: str | None = ...,
    *,
    default: None,
    primary: bool = ...,
    not_null: bool = ...,
) -> Null[time]

Create a :class:Time column.

Source code in src/embar/column/pg.py
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
def time_col(
    name: str | None = None,
    *,
    default: time | None | _NoDefaultType = NO_DEFAULT,
    primary: bool = False,
    not_null: bool = False,
) -> Time | Null[time]:
    """Create a :class:`Time` column."""
    if default is None:
        return Null[time](sql_type="TIME", py_type=time, name=name, default=default, primary=primary, not_null=not_null)
    return Time(name=name, default=default, primary=primary, not_null=not_null)

timestamp(name=None, *, default=NO_DEFAULT, primary=False, not_null=False)

timestamp(
    name: str | None = ...,
    *,
    primary: bool = ...,
    not_null: bool = ...,
) -> Timestamp
timestamp(
    name: str | None = ...,
    *,
    default: datetime,
    primary: bool = ...,
    not_null: bool = ...,
) -> Timestamp
timestamp(
    name: str | None = ...,
    *,
    default: None,
    primary: bool = ...,
    not_null: bool = ...,
) -> NullTimestamp

Create a :class:Timestamp column.

Source code in src/embar/column/pg.py
593
594
595
596
597
598
599
600
601
602
603
604
605
def timestamp(
    name: str | None = None,
    *,
    default: datetime | None | _NoDefaultType = NO_DEFAULT,
    primary: bool = False,
    not_null: bool = False,
) -> Timestamp | NullTimestamp:
    """Create a :class:`Timestamp` column."""
    if default is None:
        return Null[datetime](
            sql_type="TIMESTAMP", py_type=str, name=name, default=default, primary=primary, not_null=not_null
        )
    return Timestamp(name=name, default=default, primary=primary, not_null=not_null)

varchar(name=None, *, default=NO_DEFAULT, primary=False, not_null=False, length=None, fk=None, on_delete=None)

varchar(
    name: str | None = ...,
    *,
    primary: bool = ...,
    not_null: bool = ...,
    length: int | None = ...,
    fk: Callable[[], Column[str]] | None = ...,
    on_delete: OnDelete | None = ...,
) -> Varchar
varchar(
    name: str | None = ...,
    *,
    default: str,
    primary: bool = ...,
    not_null: bool = ...,
    length: int | None = ...,
    fk: Callable[[], Column[str]] | None = ...,
    on_delete: OnDelete | None = ...,
) -> Varchar
varchar(
    name: str | None = ...,
    *,
    default: None,
    primary: bool = ...,
    not_null: bool = ...,
    length: int | None = ...,
    fk: Callable[[], Column[str]] | None = ...,
    on_delete: OnDelete | None = ...,
) -> NullVarchar

Create a :class:Varchar column.

Source code in src/embar/column/pg.py
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
def varchar(
    name: str | None = None,
    *,
    default: str | None | _NoDefaultType = NO_DEFAULT,
    primary: bool = False,
    not_null: bool = False,
    length: int | None = None,
    fk: Callable[[], Column[str]] | None = None,
    on_delete: OnDelete | None = None,
) -> Varchar | NullVarchar:
    """Create a :class:`Varchar` column."""
    col: Varchar | Null[str]
    if default is None:
        col = Null[str](sql_type="VARCHAR", py_type=str, name=name, default=default, primary=primary, not_null=not_null)
        if length is not None:
            col._extra_args = (length,)
    else:
        col = Varchar(name=name, default=default, primary=primary, not_null=not_null, length=length)
    if fk is not None:
        col.fk(fk, on_delete)
    return col

vector(length, name=None, *, default=NO_DEFAULT, primary=False, not_null=False)

vector(
    length: int,
    name: str | None = ...,
    *,
    primary: bool = ...,
    not_null: bool = ...,
) -> Vector
vector(
    length: int,
    name: str | None = ...,
    *,
    default: list[float],
    primary: bool = ...,
    not_null: bool = ...,
) -> Vector
vector(
    length: int,
    name: str | None = ...,
    *,
    default: None,
    primary: bool = ...,
    not_null: bool = ...,
) -> Null[list[float]]

Create a :class:Vector column.

Source code in src/embar/column/pg.py
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
def vector(
    length: int,
    name: str | None = None,
    *,
    default: list[float] | None | _NoDefaultType = NO_DEFAULT,
    primary: bool = False,
    not_null: bool = False,
) -> Vector | Null[list[float]]:
    """Create a :class:`Vector` column."""
    if default is None:
        col: Null[list[float]] = Null[list[float]](
            sql_type="VECTOR", py_type=list, name=name, default=default, primary=primary, not_null=not_null
        )
        col._extra_args = (length,)
        return col
    return Vector(length, name=name, default=default, primary=primary, not_null=not_null)