summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/context.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-08-11 10:20:49 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2022-08-11 11:04:01 -0400
commit6f75807063771496a34b7725d2565acf2528d76f (patch)
tree64cdae6565c3001326ccb853eacb96a7c3f2c4ac /lib/sqlalchemy/orm/context.py
parentc4b7f1f7c9745a72f22886e6ca487f3c631a20f5 (diff)
downloadsqlalchemy-6f75807063771496a34b7725d2565acf2528d76f.tar.gz
reorg bulk persistence into a separate module
This restores persistence.py to only functions that are used by unitofwork.py, and all the "bulk" stuff gets its own module bulk_persistence.py. Also fixes up the ORM context class hierarchy for bulk. This is all ahead of the ORM-insert changes coming in, so that the later review can be about logic and not about reorganization. Change-Id: I035896e9e77fcece866d246edf30097cccad0182
Diffstat (limited to 'lib/sqlalchemy/orm/context.py')
-rw-r--r--lib/sqlalchemy/orm/context.py45
1 files changed, 44 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/context.py b/lib/sqlalchemy/orm/context.py
index 20a03e9b4..f8ea23139 100644
--- a/lib/sqlalchemy/orm/context.py
+++ b/lib/sqlalchemy/orm/context.py
@@ -206,7 +206,50 @@ _orm_load_exec_options = util.immutabledict(
)
-class ORMCompileState(CompileState):
+class AbstractORMCompileState(CompileState):
+ @classmethod
+ def create_for_statement(
+ cls,
+ statement: Union[Select, FromStatement],
+ compiler: Optional[SQLCompiler],
+ **kw: Any,
+ ) -> ORMCompileState:
+ """Create a context for a statement given a :class:`.Compiler`.
+ This method is always invoked in the context of SQLCompiler.process().
+ For a Select object, this would be invoked from
+ SQLCompiler.visit_select(). For the special FromStatement object used
+ by Query to indicate "Query.from_statement()", this is called by
+ FromStatement._compiler_dispatch() that would be called by
+ SQLCompiler.process().
+ """
+ return super().create_for_statement(statement, compiler, **kw)
+
+ @classmethod
+ def orm_pre_session_exec(
+ cls,
+ session,
+ statement,
+ params,
+ execution_options,
+ bind_arguments,
+ is_reentrant_invoke,
+ ):
+ raise NotImplementedError()
+
+ @classmethod
+ def orm_setup_cursor_result(
+ cls,
+ session,
+ statement,
+ params,
+ execution_options,
+ bind_arguments,
+ result,
+ ):
+ raise NotImplementedError()
+
+
+class ORMCompileState(AbstractORMCompileState):
class default_compile_options(CacheableOptions):
_cache_key_traversal = [
("_use_legacy_query_style", InternalTraversal.dp_boolean),