##// END OF EJS Templates
pull-requests: fix potential crash on providing a wrong order-by type column.
super-admin -
r4716:09a1d944 default
parent child Browse files
Show More
@@ -345,14 +345,14 b' class PullRequestModel(BaseModel):'
345 if only_created:
345 if only_created:
346 q = q.filter(PullRequest.pull_request_state == PullRequest.STATE_CREATED)
346 q = q.filter(PullRequest.pull_request_state == PullRequest.STATE_CREATED)
347
347
348 if order_by:
348 order_map = {
349 order_map = {
349 'name_raw': PullRequest.pull_request_id,
350 'name_raw': PullRequest.pull_request_id,
350 'id': PullRequest.pull_request_id,
351 'id': PullRequest.pull_request_id,
351 'title': PullRequest.title,
352 'title': PullRequest.title,
352 'updated_on_raw': PullRequest.updated_on,
353 'updated_on_raw': PullRequest.updated_on,
353 'target_repo': PullRequest.target_repo_id
354 'target_repo': PullRequest.target_repo_id
354 }
355 }
355 if order_by and order_by in order_map:
356 if order_dir == 'asc':
356 if order_dir == 'asc':
357 q = q.order_by(order_map[order_by].asc())
357 q = q.order_by(order_map[order_by].asc())
358 else:
358 else:
@@ -499,13 +499,13 b' class PullRequestModel(BaseModel):'
499 pull_request_alias.description.ilike(like_expression),
499 pull_request_alias.description.ilike(like_expression),
500 ))
500 ))
501
501
502 if order_by:
502 order_map = {
503 order_map = {
503 'name_raw': pull_request_alias.pull_request_id,
504 'name_raw': pull_request_alias.pull_request_id,
504 'title': pull_request_alias.title,
505 'title': pull_request_alias.title,
505 'updated_on_raw': pull_request_alias.updated_on,
506 'updated_on_raw': pull_request_alias.updated_on,
506 'target_repo': pull_request_alias.target_repo_id
507 'target_repo': pull_request_alias.target_repo_id
507 }
508 }
508 if order_by and order_by in order_map:
509 if order_dir == 'asc':
509 if order_dir == 'asc':
510 q = q.order_by(order_map[order_by].asc())
510 q = q.order_by(order_map[order_by].asc())
511 else:
511 else:
@@ -585,13 +585,14 b' class PullRequestModel(BaseModel):'
585 PullRequest.title.ilike(like_expression),
585 PullRequest.title.ilike(like_expression),
586 PullRequest.description.ilike(like_expression),
586 PullRequest.description.ilike(like_expression),
587 ))
587 ))
588 if order_by:
588
589 order_map = {
589 order_map = {
590 'name_raw': PullRequest.pull_request_id,
590 'name_raw': PullRequest.pull_request_id,
591 'title': PullRequest.title,
591 'title': PullRequest.title,
592 'updated_on_raw': PullRequest.updated_on,
592 'updated_on_raw': PullRequest.updated_on,
593 'target_repo': PullRequest.target_repo_id
593 'target_repo': PullRequest.target_repo_id
594 }
594 }
595 if order_by and order_by in order_map:
595 if order_dir == 'asc':
596 if order_dir == 'asc':
596 q = q.order_by(order_map[order_by].asc())
597 q = q.order_by(order_map[order_by].asc())
597 else:
598 else:
@@ -665,13 +666,13 b' class PullRequestModel(BaseModel):'
665 pull_request_alias.description.ilike(like_expression),
666 pull_request_alias.description.ilike(like_expression),
666 ))
667 ))
667
668
668 if order_by:
669 order_map = {
669 order_map = {
670 'name_raw': pull_request_alias.pull_request_id,
670 'name_raw': pull_request_alias.pull_request_id,
671 'title': pull_request_alias.title,
671 'title': pull_request_alias.title,
672 'updated_on_raw': pull_request_alias.updated_on,
672 'updated_on_raw': pull_request_alias.updated_on,
673 'target_repo': pull_request_alias.target_repo_id
673 'target_repo': pull_request_alias.target_repo_id
674 }
674 }
675 if order_by and order_by in order_map:
675 if order_dir == 'asc':
676 if order_dir == 'asc':
676 q = q.order_by(order_map[order_by].asc())
677 q = q.order_by(order_map[order_by].asc())
677 else:
678 else:
General Comments 0
You need to be logged in to leave comments. Login now