@@ -218,6 +218,8 @@ async def update(
218
218
auto_expunge : bool | None = None ,
219
219
auto_refresh : bool | None = None ,
220
220
id_attribute : str | InstrumentedAttribute [Any ] | None = None ,
221
+ load : LoadSpec | None = None ,
222
+ execution_options : dict [str , Any ] | None = None ,
221
223
) -> ModelT : ...
222
224
223
225
async def update_many (
@@ -1109,7 +1111,6 @@ async def count(
1109
1111
"""
1110
1112
with wrap_sqlalchemy_exception ():
1111
1113
statement = self .statement if statement is None else statement
1112
- fragment = self .get_id_attribute_value (self .model_type )
1113
1114
loader_options , loader_options_have_wildcard = self ._get_loader_options (load )
1114
1115
statement = self ._get_base_stmt (
1115
1116
statement = statement ,
@@ -1119,7 +1120,7 @@ async def count(
1119
1120
statement = self ._apply_filters (* filters , apply_pagination = False , statement = statement )
1120
1121
statement = self ._filter_select_by_kwargs (statement , kwargs )
1121
1122
statement = statement .add_criteria (
1122
- lambda s : s .with_only_columns (sql_func .count (fragment ), maintain_column_froms = True ).order_by (None ),
1123
+ lambda s : s .with_only_columns (sql_func .count (text ( "1" ) ), maintain_column_froms = True ).order_by (None ),
1123
1124
)
1124
1125
results = await self ._execute (statement , uniquify = loader_options_have_wildcard )
1125
1126
return cast (int , results .scalar_one ())
@@ -1133,6 +1134,8 @@ async def update(
1133
1134
auto_expunge : bool | None = None ,
1134
1135
auto_refresh : bool | None = None ,
1135
1136
id_attribute : str | InstrumentedAttribute [Any ] | None = None ,
1137
+ load : LoadSpec | None = None ,
1138
+ execution_options : dict [str , Any ] | None = None ,
1136
1139
) -> ModelT :
1137
1140
"""Update instance with the attribute values present on `data`.
1138
1141
@@ -1152,6 +1155,8 @@ async def update(
1152
1155
:class:`SQLAlchemyAsyncRepository.auto_commit <SQLAlchemyAsyncRepository>`
1153
1156
id_attribute: Allows customization of the unique identifier to use for model fetching.
1154
1157
Defaults to `id`, but can reference any surrogate or candidate key for the table.
1158
+ load: Set relationships to be loaded
1159
+ execution_options: Set default execution options
1155
1160
1156
1161
Returns:
1157
1162
The updated instance.
@@ -1165,7 +1170,7 @@ async def update(
1165
1170
id_attribute = id_attribute ,
1166
1171
)
1167
1172
# this will raise for not found, and will put the item in the session
1168
- await self .get (item_id , id_attribute = id_attribute )
1173
+ await self .get (item_id , id_attribute = id_attribute , load = load , execution_options = execution_options )
1169
1174
# this will merge the inbound data to the instance we just put in the session
1170
1175
instance = await self ._attach_to_session (data , strategy = "merge" )
1171
1176
await self ._flush_or_commit (auto_commit = auto_commit )
0 commit comments