diff options
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 60ec09771..a11d83b11 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -529,6 +529,18 @@ class Compiled: """ + dml_compile_state: Optional[CompileState] = None + """Optional :class:`.CompileState` assigned at the same point that + .isinsert, .isupdate, or .isdelete is assigned. + + This will normally be the same object as .compile_state, with the + exception of cases like the :class:`.ORMFromStatementCompileState` + object. + + .. versionadded:: 1.4.40 + + """ + cache_key: Optional[CacheKey] = None """The :class:`.CacheKey` that was generated ahead of creating this :class:`.Compiled` object. @@ -4371,6 +4383,8 @@ class SQLCompiler(Compiled): if toplevel: self.isinsert = True + if not self.dml_compile_state: + self.dml_compile_state = compile_state if not self.compile_state: self.compile_state = compile_state @@ -4548,6 +4562,8 @@ class SQLCompiler(Compiled): toplevel = not self.stack if toplevel: self.isupdate = True + if not self.dml_compile_state: + self.dml_compile_state = compile_state if not self.compile_state: self.compile_state = compile_state @@ -4683,6 +4699,8 @@ class SQLCompiler(Compiled): toplevel = not self.stack if toplevel: self.isdelete = True + if not self.dml_compile_state: + self.dml_compile_state = compile_state if not self.compile_state: self.compile_state = compile_state |