Adapters
Adapters translate between a data source (SQLModel, SQLAlchemy, or custom) and HyperAdmin's view layer.
Built-in Adapters
| Adapter | Module | Works with |
|---|---|---|
SQLModelAdapter |
hyperadmin.adapters.sqlmodel |
SQLModel async models |
SQLAlchemyAdapter |
hyperadmin.adapters.sqlalchemy |
SQLAlchemy async models |
HyperAdmin auto-selects the right adapter at registration time via the adapter registry.
Writing a custom adapter
Subclass BaseAdapter and implement all abstract methods:
from hyperadmin.core.adapters import BaseAdapter
class MyAdapter(BaseAdapter):
async def get(self, pk):
...
async def list(self, page=1, page_size=10, search=None, filters=None, order_by=None):
# Return (items, total_count)
...
async def create(self, data):
...
async def update(self, pk, data):
...
async def delete(self, pk):
...
async def get_related(self, pk, field):
...
async def get_schema(self):
...
filters is either a legacy {column: value} equality dict or a
Sequence[FilterCondition] (hyperadmin.core.filtering). Call
hyperadmin.core.filtering.normalize_filters(filters) to always get
list[FilterCondition] (ops: exact/gte/lte/in/isnull) before building your
query.
Register it with the adapter registry so HyperAdmin can discover it automatically:
from hyperadmin.adapters.registry import adapter_registry
adapter_registry.register(MyModel, MyAdapter)
Inline formsets and row scoping
If your adapter supports inline formsets (it implements save_inline_rows), it
must also implement inline_child_pks(spec, parent_pk) and return the primary
keys of the spec.model rows whose spec.fk_field equals parent_pk. Before
any write, HyperAdmin checks that every submitted inline row pk is one of those
keys. The default implementation returns an empty set, so without an override
every save of a parent that has existing inline rows is rejected with 404.
Row scoping from ModelAdmin.get_queryset reaches adapters through
self._resolve_queryset_filters() (for the adapter's own model) and
hyperadmin.core.adapters.scoped_queryset_filters(model) (for related models,
for example in get_choices). Apply both as equality filters on every read.
API Reference
hyperadmin.core.adapters.BaseAdapter
Bases: ABC
Abstract base class for data adapters.
Defines the contract for all data operations (get, list, create, update, delete). Subclass this to add support for a new ORM or data source.
Example
class MyAdapter(BaseAdapter):
async def get(self, pk): ...
Source code in src/hyperadmin/core/adapters.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 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 239 240 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 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 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 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 | |
create(data)
abstractmethod
async
Creates a new object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
A dictionary of data for the new object. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The created object. |
Source code in src/hyperadmin/core/adapters.py
407 408 409 410 411 412 413 414 415 416 417 418 | |
datetime_kind(field)
Return whether field stores timezone-aware or naive datetimes.
The default reads the pydantic annotation only: AwareDatetime is
"aware", any other datetime is "naive" and non-datetime or unknown
fields return None. ORM adapters override this with column introspection.
Source code in src/hyperadmin/core/adapters.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 | |
delete(pk)
abstractmethod
async
Deletes an object by its primary key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pk
|
Any
|
The primary key of the object to delete. |
required |
Source code in src/hyperadmin/core/adapters.py
434 435 436 437 438 439 440 441 442 | |
ensure_inline_rows_owned(spec, rows, parent_pk)
async
Raise :class:InlineRowNotOwnedError unless every _pk is a child of the parent.
Must run before any write. A submitted child pk is never trusted on its
own: it must be an existing child (fk_field == parent_pk) of the
parent being saved. Adapters provide the lookup via :meth:inline_child_pks,
which returns DB-typed keys (e.g. uuid.UUID for a UUID-keyed child).
A submitted _pk is a key already parsed by InlineFormset with the
child's codec, or whatever a direct adapter caller passes. It is parsed
(again) through the child model's own primary-key codec (not the
parent's) before comparing against owned, so a
UUID-keyed child's submitted str(uuid) compares equal to the
uuid.UUID instances inline_child_pks returns, instead of every
row with an existing _pk being rejected as foreign.
Source code in src/hyperadmin/core/adapters.py
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | |
for_model(model)
Return a new adapter of this same class for model.
Carries over this adapter's engine and session_factory so the new
adapter shares the same database connection seam — used to construct inline
/ related-model adapters instead of reaching for a concrete adapter class
and self.engine directly (which breaks a session_factory=-only
admin).
session_factory is forwarded only when set, so a third-party
BaseAdapter subclass that still uses the pre-0.5.8, engine-only
__init__(self, model, engine) signature keeps working unchanged
(it never sees an unexpected session_factory keyword).
Source code in src/hyperadmin/core/adapters.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
get(pk)
abstractmethod
async
Retrieves a single object by its primary key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pk
|
Any
|
The primary key of the object to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The retrieved object, or None if not found. |
Source code in src/hyperadmin/core/adapters.py
365 366 367 368 369 370 371 372 373 374 375 376 | |
get_choices(field, q='', limit=50, offset=0, label_fn=None, **filters)
abstractmethod
async
Return paginated, searchable choices for a relation field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
The relation field name on this adapter's model. |
required |
q
|
str
|
Optional search string (ILIKE match on string columns). |
''
|
limit
|
int
|
Max results to return. Must not exceed 200. |
50
|
offset
|
int
|
Number of rows to skip for pagination. |
0
|
label_fn
|
Callable[[Any], str] | None
|
Renders each target row's option label ( |
None
|
**filters
|
Any
|
Extra equality filters forwarded to the query (cascading support). |
{}
|
Returns:
| Type | Description |
|---|---|
list[ChoiceItem]
|
A list of |
Raises:
| Type | Description |
|---|---|
ValueError
|
When |
Source code in src/hyperadmin/core/adapters.py
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 | |
get_queryset(request=None)
Return additional equality filters merged into list() and get() queries.
The returned mapping has the shape {column_name: value} and is applied as
equality predicates before any view-layer filters. Use this hook to implement
features like row-level security or tenant scoping without leaking those concerns
into the view layer.
Subclasses may override this method directly, or callers may register a
per-request callable via :meth:set_queryset_filter. The callable is
re-evaluated on every list() / get() — no caching — so it must be pure
or request-scoped.
Default behaviour returns an empty dict, which is a no-op (backward compatible).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request | None
|
The active Starlette/FastAPI request, when available. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dict of column-name to value pairs to be ANDed into the query's WHERE |
dict[str, Any]
|
clause. Returns |
Source code in src/hyperadmin/core/adapters.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | |
get_related(pk, field)
abstractmethod
async
Retrieves related objects for a given object and field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pk
|
Any
|
The primary key of the object. |
required |
field
|
str
|
The name of the relationship field. |
required |
Returns:
| Type | Description |
|---|---|
list[Any]
|
A list of related objects. |
Source code in src/hyperadmin/core/adapters.py
444 445 446 447 448 449 450 451 452 453 454 455 456 | |
get_schema()
abstractmethod
async
Retrieves the schema definition for the model.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary representing the model's schema. |
Source code in src/hyperadmin/core/adapters.py
458 459 460 461 462 463 464 465 466 | |
inline_child_pks(spec, parent_pk)
async
Return the primary keys of spec.model rows whose FK points at parent_pk.
Adapters that support inline formsets override this. The default vouches for no key, so any submitted child pk is rejected.
Source code in src/hyperadmin/core/adapters.py
357 358 359 360 361 362 363 | |
list(page=1, page_size=10, search=None, filters=None, order_by=None, search_fields=None)
abstractmethod
async
Retrieves a list of objects with optional pagination, searching, and filtering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page
|
int
|
The page number for pagination. |
1
|
page_size
|
int
|
The number of items per page. |
10
|
search
|
str | None
|
A search query to filter the results. |
None
|
filters
|
Mapping[str, Any] | Sequence[FilterCondition] | None
|
Either the legacy |
None
|
order_by
|
str | None
|
The field to order the results by. |
None
|
Returns:
| Type | Description |
|---|---|
tuple[list[Any], int]
|
A tuple containing the list of objects and the total count of objects. |
Source code in src/hyperadmin/core/adapters.py
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | |
save_inline_rows(spec, rows, parent_pk)
abstractmethod
async
Persist validated inline rows — create, update, or delete as needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
InlineModelSpec
|
The |
required |
rows
|
list[dict[str, Any]]
|
Validated row dicts, each optionally containing |
required |
parent_pk
|
Any
|
The primary key of the parent object to associate new rows with. |
required |
Source code in src/hyperadmin/core/adapters.py
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 | |
set_queryset_filter(filter_fn)
Register a per-request callable that returns additional queryset filters.
The callable receives the current :class:starlette.requests.Request (or
None) and must return a dict of {column_name: value} equality filters.
It is re-invoked on every list() / get() so it may consult
request-scoped state (e.g. request.state.user).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filter_fn
|
QuerysetFilter
|
A callable taking an optional :class: |
required |
Source code in src/hyperadmin/core/adapters.py
282 283 284 285 286 287 288 289 290 291 292 293 294 | |
update(pk, data)
abstractmethod
async
Updates an existing object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pk
|
Any
|
The primary key of the object to update. |
required |
data
|
dict[str, Any]
|
A dictionary of data to update the object with. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The updated object. |
Source code in src/hyperadmin/core/adapters.py
420 421 422 423 424 425 426 427 428 429 430 431 432 | |
hyperadmin.adapters.sqlmodel.SQLModelAdapter
Bases: BaseAdapter
Data adapter for SQLModel.
Source code in src/hyperadmin/adapters/sqlmodel.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 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 206 207 208 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 239 240 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 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 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 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | |
create(data)
async
Creates a new object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
A dictionary of data for the new object. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The created object. |
Source code in src/hyperadmin/adapters/sqlmodel.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |
datetime_kind(field)
Return the column-introspected datetime kind for field.
Overrides :meth:BaseAdapter.datetime_kind (annotation-only) with the
full rule set in :func:hyperadmin.adapters.introspection.datetime_kind,
which also inspects the mapped column type.
Source code in src/hyperadmin/adapters/sqlmodel.py
44 45 46 47 48 49 50 51 52 53 54 | |
delete(pk)
async
Deletes an object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pk
|
Any
|
The primary key of the object to delete. |
required |
Raises:
| Type | Description |
|---|---|
InvalidPrimaryKey
|
If |
NotImplementedError
|
For a composite primary key. |
Source code in src/hyperadmin/adapters/sqlmodel.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
get(pk)
async
Retrieves a single object by its primary key.
Any filters returned by :meth:get_queryset are merged into the WHERE clause
before the primary-key predicate so excluded rows resolve to None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pk
|
Any
|
The primary key of the object to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The retrieved object, or |
Any
|
parse as this model's key type. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
For a composite primary key. |
Source code in src/hyperadmin/adapters/sqlmodel.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
get_choices(field, q='', limit=50, offset=0, label_fn=None, **filters)
async
Return paginated, searchable choices for a relation field.
Performs a single SELECT on the related model — no N+1.
Source code in src/hyperadmin/adapters/sqlmodel.py
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | |
get_related(pk, field)
async
Retrieves related objects for a given object and field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pk
|
Any
|
The primary key of the object. |
required |
field
|
str
|
The name of the related field. |
required |
Returns:
| Type | Description |
|---|---|
list[Any]
|
A list of related objects, or |
list[Any]
|
not parse as this model's key type. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
For a composite primary key. |
Source code in src/hyperadmin/adapters/sqlmodel.py
235 236 237 238 239 240 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 | |
get_schema()
async
Returns the JSON schema for the model.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary representing the JSON schema. |
Source code in src/hyperadmin/adapters/sqlmodel.py
269 270 271 272 273 274 275 276 | |
inline_child_pks(spec, parent_pk)
async
Return the primary keys of spec.model rows owned by parent_pk.
Source code in src/hyperadmin/adapters/sqlmodel.py
391 392 393 394 395 396 397 398 | |
list(page=1, page_size=10, search=None, filters=None, order_by=None, search_fields=None)
async
Retrieves a list of objects with optional pagination, searching, and filtering.
Filters returned by :meth:get_queryset are applied before any
view-layer filters so they cannot be bypassed. The same predicates are
included in the count query, keeping pagination math consistent.
filters accepts either the legacy {column: value} equality
mapping or a Sequence[FilterCondition]; both are resolved through
:func:hyperadmin.core.filtering.normalize_filters and compiled to
clauses via :mod:hyperadmin.adapters._filter_clause, shared with
:class:~hyperadmin.adapters.sqlalchemy.SQLAlchemyAdapter.
Source code in src/hyperadmin/adapters/sqlmodel.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
save_inline_rows(spec, rows, parent_pk)
async
Persist validated inline rows — create, update, or delete as needed.
A fresh SQLModelAdapter is constructed for the inline model via
:meth:for_model, so it shares this adapter's engine or
session_factory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
InlineModelSpec
|
The |
required |
rows
|
list[dict[str, Any]]
|
Validated row dicts, each optionally containing |
required |
parent_pk
|
Any
|
The primary key of the parent object to associate new rows with. |
required |
Raises:
| Type | Description |
|---|---|
InlineRowNotOwnedError
|
Before any write, when a submitted |
Source code in src/hyperadmin/adapters/sqlmodel.py
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 | |
update(pk, data)
async
Updates an existing object.
Primary-key attributes in data are dropped before assignment, so the
key is always immutable through this method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pk
|
Any
|
The primary key of the object to update. |
required |
data
|
dict[str, Any]
|
A dictionary of data to update the object with. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The updated object. |
Raises:
| Type | Description |
|---|---|
InvalidPrimaryKey
|
If |
NotImplementedError
|
For a composite primary key. |
Source code in src/hyperadmin/adapters/sqlmodel.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
hyperadmin.adapters.sqlalchemy.SQLAlchemyAdapter
Bases: BaseAdapter
Source code in src/hyperadmin/adapters/sqlalchemy.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 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 206 207 208 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 239 240 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 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 | |
datetime_kind(field)
Return the column-introspected datetime kind for field.
Overrides :meth:BaseAdapter.datetime_kind (annotation-only) with the
full rule set in :func:hyperadmin.adapters.introspection.datetime_kind,
which also inspects the mapped column type.
Source code in src/hyperadmin/adapters/sqlalchemy.py
44 45 46 47 48 49 50 51 52 53 54 | |
delete(pk)
async
Delete an object by primary key.
Raises:
| Type | Description |
|---|---|
InvalidPrimaryKey
|
If |
NotImplementedError
|
For a composite primary key. |
Source code in src/hyperadmin/adapters/sqlalchemy.py
181 182 183 184 185 186 187 188 189 190 191 192 193 | |
get(pk)
async
Retrieve an object by primary key, applying any get_queryset filters.
Filters returned by :meth:get_queryset are ANDed with the primary-key
predicate so excluded rows resolve to None (not raised). pk that
does not parse as this model's key type also resolves to None.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
For a composite primary key. |
Source code in src/hyperadmin/adapters/sqlalchemy.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
get_choices(field, q='', limit=50, offset=0, label_fn=None, **filters)
async
Return paginated, searchable choices for a relation field.
Performs a single SELECT on the related model — no N+1.
Source code in src/hyperadmin/adapters/sqlalchemy.py
238 239 240 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 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | |
get_related(pk, field)
async
Retrieve related objects for a given object and field.
Returns [] if not found, or if pk does not parse as this
model's key type.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
For a composite primary key. |
Source code in src/hyperadmin/adapters/sqlalchemy.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 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 | |
inline_child_pks(spec, parent_pk)
async
Return the primary keys of spec.model rows owned by parent_pk.
Source code in src/hyperadmin/adapters/sqlalchemy.py
351 352 353 354 355 356 357 358 | |
list(page=1, page_size=10, search=None, filters=None, order_by=None, search_fields=None)
async
Retrieve a paginated, filtered, searched and ordered list of objects.
filters accepts either the legacy {column: value} equality
mapping or a Sequence[FilterCondition]; both are resolved through
:func:hyperadmin.core.filtering.normalize_filters and compiled to
clauses via :mod:hyperadmin.adapters._filter_clause, shared with
:class:~hyperadmin.adapters.sqlmodel.SQLModelAdapter.
Source code in src/hyperadmin/adapters/sqlalchemy.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
save_inline_rows(spec, rows, parent_pk)
async
Persist validated inline rows — create, update, or delete as needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
InlineModelSpec
|
The |
required |
rows
|
list[dict[str, Any]]
|
Validated row dicts, each optionally containing |
required |
parent_pk
|
Any
|
The primary key of the parent object to associate new rows with. |
required |
Raises:
| Type | Description |
|---|---|
InlineRowNotOwnedError
|
Before any write, when a submitted |
Source code in src/hyperadmin/adapters/sqlalchemy.py
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | |
update(pk, data)
async
Update an existing object.
Primary-key attributes in data are dropped before assignment, so the
key is always immutable through this method.
Raises:
| Type | Description |
|---|---|
InvalidPrimaryKey
|
If |
NotImplementedError
|
For a composite primary key. |
Source code in src/hyperadmin/adapters/sqlalchemy.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |