bito-code-review[bot] commented on code in PR #42785:
URL: https://github.com/apache/superset/pull/42785#discussion_r3964835864


##########
tests/unit_tests/jinja_context_test.py:
##########
@@ -3416,3 +3416,81 @@ def 
test_get_rendered_sql_filter_values_index_error_on_empty_list() -> None:
         match=r"Virtual dataset template error: list object has no element 0",
     ):
         table.get_rendered_sql(processor)
+
+
[email protected](
+    "sql,expected",
+    [
+        pytest.param("SELECT 1", False, id="plain"),
+        pytest.param("SELECT '{{ current_username() }}'", True, 
id="expression"),
+        pytest.param("{% set a = 1 %}SELECT {{ a }}", True, id="statement"),
+        # A comment leaves no trace in a parsed template, but still has to be
+        # expanded away before the SQL is SQL.
+        pytest.param("SELECT 1 {# a comment #}", True, id="comment"),
+        # A whole query that is one macro lexes without a `data` token at all.
+        pytest.param("{{ dataset(1) }}", True, id="template_only"),
+        # Merely containing braces is not templating: the array literal opens
+        # like a template and is abandoned unterminated, and the JSON literal 
is
+        # never even mistaken for one.
+        pytest.param("SELECT '{{1,2},{3,4}}'::int[]", False, 
id="postgres_array"),
+        pytest.param("""SELECT '{"a": 1}'::json""", False, id="json_literal"),
+        # A real template alongside an array literal is still a template: the
+        # first construct closes before the lexer gives up on the second.
+        pytest.param(
+            "SELECT '{{ current_username() }}', '{{1,2},{3,4}}'::int[]",
+            True,
+            id="template_beside_array",
+        ),
+    ],
+)
+def test_has_template(sql: str, expected: bool) -> None:

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Missing feature-flag decorator</b></div>
   <div id="fix">
   
   `test_has_template` lacks 
`@with_feature_flags(ENABLE_TEMPLATE_PROCESSING=True)`. The default flag is 
`False` (config.py:920) and no fixture enables it, so `get_template_processor` 
returns `NoOpTemplateProcessor`, whose `has_template` always returns `False`. 
The `expected=True` parametrized cases 
(expression/statement/comment/template_only/template_beside_array) will fail. 
Add the decorator, mirroring `test_has_template_when_processing_is_disabled`.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #8cc6ce</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
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]

Reply via email to