Skip to content

Commit

Permalink
Merge branch 'main' into channels-use-finally
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn authored Oct 15, 2024
2 parents 762cecd + 1a4f1a3 commit 928cca9
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
10 changes: 5 additions & 5 deletions docs/examples/contrib/sqlalchemy/sqlalchemy_async_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class BaseModel(_BaseModel):
model_config = {"from_attributes": True}


# the SQLAlchemy base includes a declarative model for you to use in your models.
# The `Base` class includes a `UUID` based primary key (`id`)
# The SQLAlchemy base includes a declarative model for you to use in your models.
# The `UUIDBase` class includes a `UUID` based primary key (`id`)
class AuthorModel(base.UUIDBase):
# we can optionally provide the table name instead of auto-generating it
__tablename__ = "author" # type: ignore[assignment]
Expand All @@ -44,9 +44,9 @@ class AuthorModel(base.UUIDBase):
books: Mapped[list[BookModel]] = relationship(back_populates="author", lazy="noload")


# The `AuditBase` class includes the same UUID` based primary key (`id`) and 2
# additional columns: `created` and `updated`. `created` is a timestamp of when the
# record created, and `updated` is the last time the record was modified.
# The `UUIDAuditBase` class includes the same UUID` based primary key (`id`) and 2
# additional columns: `created_at` and `updated_at`. `created_at` is a timestamp of when the
# record created, and `updated_at` is the last time the record was modified.
class BookModel(base.UUIDAuditBase):
__tablename__ = "book" # type: ignore[assignment]
title: Mapped[str]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
from litestar.contrib.sqlalchemy.plugins import AsyncSessionConfig, SQLAlchemyAsyncConfig, SQLAlchemyPlugin


# the SQLAlchemy base includes a declarative model for you to use in your models.
# The `Base` class includes a `UUID` based primary key (`id`)
# The SQLAlchemy base includes a declarative model for you to use in your models.
# The `UUIDBase` class includes a `UUID` based primary key (`id`)
class Author(UUIDBase):
name: Mapped[str]
dob: Mapped[date]
books: Mapped[List[Book]] = relationship(back_populates="author", lazy="selectin")


# The `AuditBase` class includes the same UUID` based primary key (`id`) and 2
# The `UUIDAuditBase` class includes the same UUID` based primary key (`id`) and 2
# additional columns: `created_at` and `updated_at`. `created_at` is a timestamp of when the
# record created, and `updated_at` is the last time the record was modified.
class Book(UUIDAuditBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ async def _is_slug_unique(
return await self.get_one_or_none(slug=slug) is None


# The `AuditBase` class includes the same UUID` based primary key (`id`) and 2
# additional columns: `created` and `updated`. `created` is a timestamp of when the
# record created, and `updated` is the last time the record was modified.
# The `UUIDAuditBase` class includes the same UUID` based primary key (`id`) and 2
# additional columns: `created_at` and `updated_at`. `created_at` is a timestamp of when the
# record created, and `updated_at` is the last time the record was modified.
class BlogPost(UUIDAuditBase, SlugKey):
title: Mapped[str]
content: Mapped[str]
Expand Down
10 changes: 5 additions & 5 deletions docs/examples/contrib/sqlalchemy/sqlalchemy_sync_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class BaseModel(_BaseModel):
model_config = {"from_attributes": True}


# the SQLAlchemy base includes a declarative model for you to use in your models.
# The `Base` class includes a `UUID` based primary key (`id`)
# The SQLAlchemy base includes a declarative model for you to use in your models.
# The `UUIDBase` class includes a `UUID` based primary key (`id`)
class AuthorModel(UUIDBase):
# we can optionally provide the table name instead of auto-generating it
__tablename__ = "author" # type: ignore[assignment]
Expand All @@ -40,9 +40,9 @@ class AuthorModel(UUIDBase):
books: Mapped[list[BookModel]] = relationship(back_populates="author", lazy="noload")


# The `AuditBase` class includes the same UUID` based primary key (`id`) and 2
# additional columns: `created` and `updated`. `created` is a timestamp of when the
# record created, and `updated` is the last time the record was modified.
# The `UUIDAuditBase` class includes the same UUID` based primary key (`id`) and 2
# additional columns: `created_at` and `updated_at`. `created_at` is a timestamp of when the
# record created, and `updated_at` is the last time the record was modified.
class BookModel(UUIDAuditBase):
__tablename__ = "book" # type: ignore[assignment]
title: Mapped[str]
Expand Down
2 changes: 1 addition & 1 deletion docs/usage/caching.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ sentinel instead:
:language: python
:caption: Caching the response indefinitely by setting the :paramref:`~litestar.handlers.HTTPRouteHandler.cache`
parameter to :class:`~litestar.config.response_cache.CACHE_FOREVER`.
:lines: 1, 3, 14-18
:lines: 1-3, 14-18
:emphasize-lines: 5

Configuration
Expand Down
4 changes: 2 additions & 2 deletions docs/usage/databases/sqlalchemy/models_and_repository.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ implementations:
* :class:`UUIDAuditBase <advanced_alchemy.base.UUIDAuditBase>`

Both include a ``UUID`` based primary key
and ``UUIDAuditBase`` includes an ``updated_at`` and ``created_at`` timestamp column.
and ``UUIDAuditBase`` includes ``updated_at`` and ``created_at`` timestamp columns.

The ``UUID`` will be a native ``UUID``/``GUID`` type on databases that support it such as Postgres. For other engines without
a native UUID data type, the UUID is stored as a 16-byte ``BYTES`` or ``RAW`` field.
Expand All @@ -45,7 +45,7 @@ a native UUID data type, the UUID is stored as a 16-byte ``BYTES`` or ``RAW`` fi
* :class:`BigIntAuditBase <advanced_alchemy.base.BigIntAuditBase>`

Both include a ``BigInteger`` based primary key
and ``BigIntAuditBase`` includes an ``updated_at`` and ``created_at`` timestamp column.
and ``BigIntAuditBase`` includes ``updated_at`` and ``created_at`` timestamp columns.

Models using these bases also include the following enhancements:

Expand Down

0 comments on commit 928cca9

Please sign in to comment.