Create an out-of-compiler ORMCompileState object. The ORMCompileState object is normally created directly as a result of the SQLCompiler.process() method being handed a Select() or FromStatement() object that uses the "orm" plugin. This method provides a means of c
(
self, for_statement: bool = False, **kw: Any
)
| 3322 | return result.rowcount |
| 3323 | |
| 3324 | def _compile_state( |
| 3325 | self, for_statement: bool = False, **kw: Any |
| 3326 | ) -> ORMCompileState: |
| 3327 | """Create an out-of-compiler ORMCompileState object. |
| 3328 | |
| 3329 | The ORMCompileState object is normally created directly as a result |
| 3330 | of the SQLCompiler.process() method being handed a Select() |
| 3331 | or FromStatement() object that uses the "orm" plugin. This method |
| 3332 | provides a means of creating this ORMCompileState object directly |
| 3333 | without using the compiler. |
| 3334 | |
| 3335 | This method is used only for deprecated cases, which include |
| 3336 | the .from_self() method for a Query that has multiple levels |
| 3337 | of .from_self() in use, as well as the instances() method. It is |
| 3338 | also used within the test suite to generate ORMCompileState objects |
| 3339 | for test purposes. |
| 3340 | |
| 3341 | """ |
| 3342 | |
| 3343 | stmt = self._statement_20(for_statement=for_statement, **kw) |
| 3344 | assert for_statement == stmt._compile_options._for_statement |
| 3345 | |
| 3346 | # this chooses between ORMFromStatementCompileState and |
| 3347 | # ORMSelectCompileState. We could also base this on |
| 3348 | # query._statement is not None as we have the ORM Query here |
| 3349 | # however this is the more general path. |
| 3350 | compile_state_cls = cast( |
| 3351 | ORMCompileState, |
| 3352 | ORMCompileState._get_plugin_class_for_plugin(stmt, "orm"), |
| 3353 | ) |
| 3354 | |
| 3355 | return compile_state_cls._create_orm_context( |
| 3356 | stmt, toplevel=True, compiler=None |
| 3357 | ) |
| 3358 | |
| 3359 | def _compile_context(self, for_statement: bool = False) -> QueryContext: |
| 3360 | compile_state = self._compile_state(for_statement=for_statement) |