codeant-ai-for-open-source[bot] commented on code in PR #41964:
URL: https://github.com/apache/superset/pull/41964#discussion_r3565544698
##########
tests/unit_tests/connectors/sqla/models_test.py:
##########
@@ -1177,3 +1177,46 @@ def
test_validate_stored_expression_rejects_subquery_around_jinja(
None,
"(SELECT password FROM ab_user LIMIT 1) {# x #}",
)
+
+
+def test_dttm_cols_excludes_column_after_temporal_flag_removed(
+ session: Session,
+) -> None:
+ """
+ Regression for #30510: when a column is mistakenly marked temporal, set as
the
+ dataset's default datetime (``main_dttm_col``) and saved, then later has
its
+ ``is_dttm`` flag removed, the dataset must stop treating that column as
temporal.
+
+ Otherwise ``dttm_cols`` (which feeds time-column selection and the default
time
+ filter for every chart built on the dataset) keeps returning a non-temporal
+ column, corrupting the dataset with a time filter that cannot be removed.
+ """
+ Database.metadata.create_all(session.bind)
+ database = Database(database_name="my_db", sqlalchemy_uri="sqlite://")
+
+ # A column the user mistakenly marks as temporal ("Is Temporal") and then
picks
+ # as the dataset "Default Datetime" (``main_dttm_col``).
+ column = TableColumn(column_name="not_really_a_date", type="VARCHAR",
is_dttm=True)
Review Comment:
✅ **Customized review instruction saved!**
**Instruction:**
> Do not require explicit type annotations for throwaway local variables in
test fixtures; mypy inference is sufficient in test code.
**Applied to:**
- `**/test/**`
- `**/tests/**`
- `**/*test*.<ext>`
---
💡 *To manage or update this instruction, visit: [CodeAnt AI
Settings](https://app.codeant.ai/org/settings/learnings)*
##########
tests/unit_tests/connectors/sqla/models_test.py:
##########
@@ -1177,3 +1177,46 @@ def
test_validate_stored_expression_rejects_subquery_around_jinja(
None,
"(SELECT password FROM ab_user LIMIT 1) {# x #}",
)
+
+
+def test_dttm_cols_excludes_column_after_temporal_flag_removed(
+ session: Session,
+) -> None:
+ """
+ Regression for #30510: when a column is mistakenly marked temporal, set as
the
+ dataset's default datetime (``main_dttm_col``) and saved, then later has
its
+ ``is_dttm`` flag removed, the dataset must stop treating that column as
temporal.
+
+ Otherwise ``dttm_cols`` (which feeds time-column selection and the default
time
+ filter for every chart built on the dataset) keeps returning a non-temporal
+ column, corrupting the dataset with a time filter that cannot be removed.
+ """
+ Database.metadata.create_all(session.bind)
+ database = Database(database_name="my_db", sqlalchemy_uri="sqlite://")
+
+ # A column the user mistakenly marks as temporal ("Is Temporal") and then
picks
+ # as the dataset "Default Datetime" (``main_dttm_col``).
+ column = TableColumn(column_name="not_really_a_date", type="VARCHAR",
is_dttm=True)
+ dataset = SqlaTable(
Review Comment:
✅ **Customized review instruction saved!**
**Instruction:**
> Avoid flagging missing explicit type annotations for simple test fixtures
in test code when the type is already inferred and the variable is only used
locally.
**Applied to:**
- `**/test/**`
- `**/tests/**`
- `**/*test*.py`
---
💡 *To manage or update this instruction, visit: [CodeAnt AI
Settings](https://app.codeant.ai/org/settings/learnings)*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]