Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion tests/integration_tests/model_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,14 @@ def query_with_expr_helper(self, is_timeseries, inner_join=True):
return None
old_inner_join = spec.allows_joins
spec.allows_joins = inner_join

# Use database-specific string concatenation syntax
arbitrary_gby = (
"state OR gender OR '_test'"
"CONCAT(state, gender, '_test')"
if get_example_database().backend == "mysql"
else "state || gender || '_test'"
)
Comment on lines +452 to 457
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect database backend detection logic

The database backend detection logic was changed to always use get_example_database().backend instead of the actual table's database backend. This will generate incorrect SQL concatenation syntax when the table is from a database with a different backend than the example database, causing SQL syntax errors in production.

Code suggestion
Check the AI-generated fix before applying
Suggested change
# Use database-specific string concatenation syntax
arbitrary_gby = (
"state OR gender OR '_test'"
"CONCAT(state, gender, '_test')"
if get_example_database().backend == "mysql"
else "state || gender || '_test'"
)
# Use database-specific string concatenation syntax
database = self.get_database_by_id(tbl.database_id)
if database.backend == "mysql":
arbitrary_gby = "CONCAT(state, gender, '_test')"
else:
# Use PostgreSQL/SQLite style for other databases
arbitrary_gby = "state || gender || '_test'"

Code Review Run #e218aa


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them


arbitrary_metric = dict( # noqa: C408
label="arbitrary", expressionType="SQL", sqlExpression="SUM(num_boys)"
)
Expand Down
Loading