sha174n commented on code in PR #41426:
URL: https://github.com/apache/superset/pull/41426#discussion_r3478622550
##########
tests/unit_tests/models/test_validate_expression.py:
##########
@@ -105,18 +106,17 @@ def test_validate_having_expression(self, mock_execute):
@patch("superset.connectors.sqla.models.SqlaTable._execute_validation_query")
def test_validate_invalid_expression(self, mock_execute):
- """Test validation of invalid SQL expressions"""
- # Mock _execute_validation_query to raise an exception
- mock_execute.side_effect = Exception("Invalid SQL syntax")
-
+ """Unparseable SQL is rejected by the shared expression parser before
the
+ validation query is built or executed."""
result = self.table.validate_expression(
expression="INVALID SQL HERE",
expression_type=SqlExpressionType.COLUMN,
)
assert result["valid"] is False
assert len(result["errors"]) == 1
- assert "Invalid SQL syntax" in result["errors"][0]["message"]
+ assert result["errors"][0]["message"]
Review Comment:
Addressed in f48973cb02: the assertion now checks the specific parser
message ("cannot be parsed as a single SQL statement") rather than truthiness,
and the two new sibling tests assert their rejection reasons too.
--
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]