Skip to content

Commit ed5e28e

Browse files
author
Dhanush Varma
committed
Fix SQLAlchemy 2.x subquery deprecation warnings in controllers
1 parent ff83b91 commit ed5e28e

4 files changed

Lines changed: 9 additions & 9 deletions

File tree

mod_ci/controllers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2437,7 +2437,7 @@ def progress_type_request(log, test, test_id, request) -> bool:
24372437
results = g.db.query(count(TestResultFile.got)).filter(
24382438
and_(
24392439
TestResultFile.test_id == test.id,
2440-
TestResultFile.regression_test_id.in_(results_zero_rc),
2440+
TestResultFile.regression_test_id.in_(results_zero_rc.select()),
24412441
TestResultFile.got.isnot(None)
24422442
)
24432443
).scalar()
@@ -2513,13 +2513,13 @@ def update_final_status():
25132513
finished_tests = g.db.query(TestProgress.test_id).filter(
25142514
and_(
25152515
TestProgress.status.in_([TestStatus.canceled, TestStatus.completed]),
2516-
TestProgress.test_id.in_(platform_tests)
2516+
TestProgress.test_id.in_(platform_tests.select())
25172517
)
25182518
).subquery()
25192519
in_progress_statuses = [TestStatus.preparation, TestStatus.completed, TestStatus.canceled]
25202520
finished_tests_progress = g.db.query(TestProgress).filter(
25212521
and_(
2522-
TestProgress.test_id.in_(finished_tests),
2522+
TestProgress.test_id.in_(finished_tests.select()),
25232523
TestProgress.status.in_(in_progress_statuses)
25242524
)
25252525
).subquery()

mod_customized/controllers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def index():
8282
g.log.error('GitHub token not configured, cannot fetch commits')
8383

8484
populated_categories = g.db.query(regressionTestLinkTable.c.category_id).subquery()
85-
categories = Category.query.filter(Category.id.in_(populated_categories)).order_by(Category.name.asc()).all()
85+
categories = Category.query.filter(Category.id.in_(populated_categories.select())).order_by(Category.name.asc()).all()
8686

8787
tests = Test.query.filter(and_(TestFork.user_id == g.user.id, TestFork.test_id == Test.id)).order_by(
8888
Test.id.desc()).limit(50).all()

mod_sample/controllers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ def display_sample_info(sample) -> Dict[str, Any]:
6969
sq = g.db.query(RegressionTest.id).filter(RegressionTest.sample_id == sample.id).subquery()
7070
exit_code = g.db.query(TestResult.exit_code).filter(and_(
7171
TestResult.exit_code != TestResult.expected_rc,
72-
and_(TestResult.test_id == test_commit.id, TestResult.regression_test_id.in_(sq))
72+
and_(TestResult.test_id == test_commit.id, TestResult.regression_test_id.in_(sq.select()))
7373
)).first()
7474
not_null = g.db.query(TestResultFile.got).filter(and_(
7575
TestResultFile.got.isnot(None),
76-
and_(TestResultFile.test_id == test_commit.id, TestResultFile.regression_test_id.in_(sq))
76+
and_(TestResultFile.test_id == test_commit.id, TestResultFile.regression_test_id.in_(sq.select()))
7777
)).first()
7878

7979
if exit_code is None and not_null is None:
@@ -87,12 +87,12 @@ def display_sample_info(sample) -> Dict[str, Any]:
8787
exit_code = g.db.query(TestResult.exit_code).filter(
8888
and_(
8989
TestResult.exit_code != TestResult.expected_rc,
90-
and_(TestResult.test_id == test_release.id, TestResult.regression_test_id.in_(sq))
90+
and_(TestResult.test_id == test_release.id, TestResult.regression_test_id.in_(sq.select()))
9191
)
9292
).first()
9393
not_null = g.db.query(TestResultFile.got).filter(and_(
9494
TestResultFile.got.isnot(None),
95-
and_(TestResultFile.test_id == test_release.id, TestResultFile.regression_test_id.in_(sq))
95+
and_(TestResultFile.test_id == test_release.id, TestResultFile.regression_test_id.in_(sq.select()))
9696
)).first()
9797

9898
if exit_code is None and not_null is None:

mod_test/controllers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def get_test_results(test) -> List[Dict[str, Any]]:
6161
:type test: Test
6262
"""
6363
populated_categories = g.db.query(regressionTestLinkTable.c.category_id).subquery()
64-
categories = Category.query.filter(Category.id.in_(populated_categories)).order_by(Category.name.asc()).all()
64+
categories = Category.query.filter(Category.id.in_(populated_categories.select())).order_by(Category.name.asc()).all()
6565
results = [{
6666
'category': category,
6767
'tests': [{

0 commit comments

Comments
 (0)