new branch#4
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 58cd707aa2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if replace: | ||
| self.drop_view(view_name, if_exists=True) | ||
| sql = f"CREATE VIEW {self._quote(view_name)} AS {select_sql}" # nosec B608 | ||
| return self.run_native(sql) |
There was a problem hiding this comment.
Make
replace=True atomic before dropping the old object
When replace=True, this path calls drop_view() and then issues CREATE VIEW as two separate run_native() calls. Outside an explicit db.transaction(), run_native() opens its own engine.begin() block per call, so an invalid replacement query (or a missing referenced table) will commit the drop and then fail the create, leaving the previously working view gone. The same destructive pattern is repeated in the procedure/function/event helpers below.
Useful? React with 👍 / 👎.
| def drop_view(self, name: str, *, if_exists: bool = True) -> Any: | ||
| view_name = self._validate_identifier(name) | ||
| sql = f"DROP VIEW {'IF EXISTS ' if if_exists else ''}{self._quote(view_name)}" # nosec B608 | ||
| return self.run_native(sql) |
There was a problem hiding this comment.
Invalidate cached schema after creating or dropping a view
find()/count() reuse reflected metadata from _table_cache and _column_type_cache, but neither create_view() nor drop_view() clears those caches. If a view has been queried once and is then recreated with a different projection via replace=True, subsequent reads on the same UDOM instance will keep using the stale column set from the old view, which can silently omit new columns or raise on removed ones.
Useful? React with 👍 / 👎.
No description provided.