|
15 | 15 | IQueryOperator, CompositeQuery, MergeConflict |
16 | 16 | ) |
17 | 17 | from ascetic_ddd.faker.domain.query.parser import parse_query |
| 18 | +from ascetic_ddd.faker.domain.query.evaluate_visitor import EvaluateWalker |
18 | 19 | from ascetic_ddd.faker.domain.query.visitors import query_to_dict |
19 | 20 | from ascetic_ddd.faker.domain.providers.exceptions import DiamondUpdateConflict |
20 | 21 | from ascetic_ddd.faker.domain.specification.empty_specification import EmptySpecification |
@@ -168,8 +169,15 @@ def require(self, criteria: dict[str, typing.Any]) -> None: |
168 | 169 | self._criteria = new_criteria |
169 | 170 | # Only reset output if input actually changed |
170 | 171 | if self._criteria != old_criteria: |
171 | | - self._input = Nothing() |
172 | | - self._output = Nothing() |
| 172 | + if self._output.is_some(): |
| 173 | + if not self.is_transient(): |
| 174 | + state = self.state() |
| 175 | + walker = EvaluateWalker() |
| 176 | + if not walker.evaluate_sync(new_criteria, state): |
| 177 | + raise DiamondUpdateConflict(state, query_to_dict(new_criteria), self.provider_name) |
| 178 | + else: |
| 179 | + self._input = Nothing() |
| 180 | + self._output = Nothing() |
173 | 181 | self._on_required.notify(CriteriaRequiredEvent(new_criteria)) |
174 | 182 |
|
175 | 183 | def output(self) -> OutputT: |
@@ -373,10 +381,7 @@ async def _set_output(self, session: ISession, output: CompositeOutputT | None, |
373 | 381 | await self._on_populated.notify(OutputPopulatedEvent(session, output, self.is_transient(), is_distributed)) |
374 | 382 |
|
375 | 383 | def is_complete(self) -> bool: |
376 | | - return ( |
377 | | - self._output.is_some() or |
378 | | - all(provider.is_complete() for provider in self.providers.values()) |
379 | | - ) |
| 384 | + return self._output.is_some() |
380 | 385 |
|
381 | 386 | def is_transient(self) -> bool: |
382 | 387 | return any(provider.is_transient() for provider in self.providers.values()) |
|
0 commit comments