diff --git a/CHANGELOG.md b/CHANGELOG.md index 26f2e35..1a89028 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,14 @@ # Changelog -## 0.14.0 +## 0.14.0 "Claims & Columns" * Added `ast` module * Deprecate `dei_args()` for problems with the typing system. The function is not going away tho * Module `sqlalchemy`: - * added `email_column()`, `ascii_column()`, `i4_column()` + * added `email_column()`, `ascii_column()`, `i4_column()`, `now_column()` * added application level checks for `match_column()` * Added common values for snowflake epoch in `SnowflakeEpoch` enum -* Module `bitÅ›`: added `i4_to_int()`, `int_to_i4()` +* Module `bits`: added `i4_to_int()`, `int_to_i4()` ## 0.13.1 and 0.12.7 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index e818cd6..0000000 --- a/requirements.txt +++ /dev/null @@ -1,14 +0,0 @@ -# This file is only used for Sphinx. -# End users should use pyproject.toml instead - -itsdangerous==2.2.0 -libsass==0.23.0 -peewee==3.18.1 -pydantic==2.12.0 -quart_schema==0.22.0 -setuptools==80.9.0 -starlette==0.48.0 -SQLAlchemy==2.0.40 -toml==0.10.2 -sphinx_rtd_theme==3.0.2 - diff --git a/src/suou/__init__.py b/src/suou/__init__.py index 351ff60..56bdc7e 100644 --- a/src/suou/__init__.py +++ b/src/suou/__init__.py @@ -41,7 +41,7 @@ from .color import OKLabColor, chalk, WebColor, RGBColor, LinearRGBColor, \ from .mat import Matrix from .argparse import LetterSubparsers -__version__ = "0.14.0a5" +__version__ = "0.14.0" __all__ = ( 'ColorFormatter', diff --git a/src/suou/sqlalchemy/__init__.py b/src/suou/sqlalchemy/__init__.py index 31260a2..c5ce526 100644 --- a/src/suou/sqlalchemy/__init__.py +++ b/src/suou/sqlalchemy/__init__.py @@ -158,7 +158,7 @@ from .asyncio import SQLAlchemy, async_query, SessionWrapper, AsyncSelectPaginat from .orm import ( id_column, snowflake_column, match_column, match_constraint, bool_column, declarative_base, parent_children, author_pair, age_pair, bound_fk, unbound_fk, want_column, a_relationship, BitSelector, secret_column, username_column, - ascii_column, i4_column + ascii_column, i4_column, now_column, ) try: @@ -173,7 +173,7 @@ __all__ = ( 'match_column', 'match_constraint', 'bool_column', 'parent_children', 'author_pair', 'age_pair', 'bound_fk', 'unbound_fk', 'want_column', 'a_relationship', 'BitSelector', 'secret_column', 'username_column', - 'ascii_column', 'i4_column', + 'ascii_column', 'i4_column', 'now_column', # .asyncio 'SQLAlchemy', 'AsyncSelectPagination', 'async_query', 'SessionWrapper' ) \ No newline at end of file diff --git a/src/suou/sqlalchemy/orm.py b/src/suou/sqlalchemy/orm.py index 3164a78..113a0e2 100644 --- a/src/suou/sqlalchemy/orm.py +++ b/src/suou/sqlalchemy/orm.py @@ -22,7 +22,7 @@ import os import re from typing import Any, Callable, TypeAlias, TypeVar import warnings -from sqlalchemy import BigInteger, Boolean, CheckConstraint, Column, Date, ForeignKey, Integer, LargeBinary, MetaData, SmallInteger, String, TypeDecorator, text +from sqlalchemy import BigInteger, Boolean, CheckConstraint, Column, Date, DateTime, ForeignKey, Integer, LargeBinary, MetaData, SmallInteger, String, TypeDecorator, func, text from sqlalchemy.orm import DeclarativeBase, InstrumentedAttribute, Relationship, declarative_base as _declarative_base, relationship from sqlalchemy.types import TypeEngine from sqlalchemy.ext.hybrid import Comparator @@ -210,6 +210,15 @@ def bool_column(value: bool = False, nullable: bool = False, **kwargs) -> Column """ def_val = text('true') if value else text('false') return Column(Boolean, server_default=def_val, nullable=nullable, **kwargs) + + +def now_column(*, nullable: bool = False, **kwargs): + """ + Column with default value set as CURRENT_TIMESTAMP. + + *New in 0.14.0* + """ + return Column(DateTime, nullable=nullable, server_default=func.current_timestamp(), **kwargs) def declarative_base(domain_name: str, master_secret: bytes, metadata: dict | None = None, **kwargs) -> type[DeclarativeBase]: