Skip to content

Commit e626875

Browse files
authored
docs: fix docs and type hint of repository.add_many (#474)
Correctly document the parameters of the `add_many` method.
1 parent b3159c8 commit e626875

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

advanced_alchemy/service/_async.py

-1
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,6 @@ async def create_many(
654654
auto_commit: Commit objects before returning.
655655
error_messages: An optional dictionary of templates to use
656656
for friendlier error messages to clients
657-
uniquify: Optionally apply the ``unique()`` method to results before returning.
658657
659658
Returns:
660659
Representation of created instances.

advanced_alchemy/service/_sync.py

-1
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,6 @@ def create_many(
653653
auto_commit: Commit objects before returning.
654654
error_messages: An optional dictionary of templates to use
655655
for friendlier error messages to clients
656-
uniquify: Optionally apply the ``unique()`` method to results before returning.
657656
658657
Returns:
659658
Representation of created instances.

docs/usage/frameworks/litestar.rst

+8-7
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ Define your SQLAlchemy models using Advanced Alchemy's enhanced base classes:
5050

5151
.. code-block:: python
5252
53+
from __future__ import annotations
5354
import datetime
5455
from uuid import UUID
5556
from sqlalchemy import ForeignKey
5657
from sqlalchemy.orm import Mapped, mapped_column, relationship
57-
from litestar.plugins.sqlalchemy.base import UUIDAuditBase, UUIDBase
58+
from advanced_alchemy.base import UUIDAuditBase, UUIDBase
5859
5960
6061
class AuthorModel(UUIDBase):
@@ -122,8 +123,8 @@ Create repository and service classes to interact with the model:
122123
123124
from typing import AsyncGenerator
124125
125-
from litestar.plugins.sqlalchemy.repository import SQLAlchemyAsyncRepository
126-
from litestar.plugins.sqlalchemy.service import SQLAlchemyAsyncRepositoryService
126+
from advanced_alchemy.repository import SQLAlchemyAsyncRepository
127+
from advanced_alchemy.service import SQLAlchemyAsyncRepositoryService
127128
from sqlalchemy.ext.asyncio import AsyncSession
128129
129130
class AuthorService(SQLAlchemyAsyncRepositoryService[AuthorModel]):
@@ -144,9 +145,9 @@ Create a controller class to handle HTTP endpoints. The controller uses dependen
144145
from litestar import Controller, get, post, patch, delete
145146
from litestar.di import Provide
146147
from litestar.params import Parameter
147-
from litestar.plugins.sqlalchemy.filters import FilterTypes
148-
from litestar.plugins.sqlalchemy.providers import create_service_dependencies
149-
from litestar.plugins.sqlalchemy.service import OffsetPagination
148+
from advanced_alchemy.filters import FilterTypes
149+
from advanced_alchemy.extensions.litestar.providers import create_service_dependencies
150+
from advanced_alchemy.service import OffsetPagination
150151
151152
class AuthorController(Controller):
152153
"""Author CRUD endpoints."""
@@ -227,12 +228,12 @@ Finally, configure your Litestar application with the plugin and dependencies:
227228
228229
from litestar import Litestar
229230
from litestar.di import Provide
230-
from litestar.plugins.sqlalchemy.filters import FilterTypes, LimitOffset
231231
from litestar.plugins.sqlalchemy import (
232232
AsyncSessionConfig,
233233
SQLAlchemyAsyncConfig,
234234
SQLAlchemyPlugin,
235235
)
236+
from advanced_alchemy.filters import FilterTypes, LimitOffset
236237
237238
sqlalchemy_config = SQLAlchemyAsyncConfig(
238239
connection_string="sqlite+aiosqlite:///test.sqlite",

docs/usage/repositories.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,16 @@ Bulk Operations
130130

131131
Repositories support efficient bulk operations:
132132

133-
Create Many
134-
-----------
133+
Add Many
134+
--------
135135

136136
.. code-block:: python
137137
138-
async def create_posts(db_session: AsyncSession, data: list[tuple[str, str, UUID]]) -> list[Post]:
138+
async def create_posts(db_session: AsyncSession, data: list[tuple[str, str, UUID]]) -> Sequence[Post]:
139139
repository = PostRepository(session=db_session)
140140
141141
# Create posts
142-
return await repository.create_many(
142+
return await repository.add_many(
143143
[Post(title=title, content=content, author_id=author_id) for title, content, author_id in data],
144144
auto_commit=True
145145
)

0 commit comments

Comments
 (0)