(self, db_session: "Session", actor: Optional["User"] = None, no_commit: bool = False)
| 373 | |
| 374 | @handle_db_timeout |
| 375 | def create(self, db_session: "Session", actor: Optional["User"] = None, no_commit: bool = False) -> "SqlalchemyBase": |
| 376 | logger.debug(f"Creating {self.__class__.__name__} with ID: {self.id} with actor={actor}") |
| 377 | |
| 378 | if actor: |
| 379 | self._set_created_and_updated_by_fields(actor.id) |
| 380 | try: |
| 381 | db_session.add(self) |
| 382 | if no_commit: |
| 383 | db_session.flush() # no commit, just flush to get PK |
| 384 | else: |
| 385 | db_session.commit() |
| 386 | db_session.refresh(self) |
| 387 | return self |
| 388 | except (DBAPIError, IntegrityError) as e: |
| 389 | self._handle_dbapi_error(e) |
| 390 | |
| 391 | @classmethod |
| 392 | @handle_db_timeout |
nothing calls this directly
no test coverage detected