Skip to content

Commit 97a264e

Browse files
Fix: Handle string boolean values in exact_match filter (#283)
The exact_match parameter from URL query args is always a string, but the code was comparing it directly to boolean True, causing it to always fail. Changed comparison to check for string 'true' value using .lower() method. Signed-off-by: Pranjal Jha <136667416+pranjal2004838@users.noreply.github.com>
1 parent db4c266 commit 97a264e

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

src/classes/package_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def searchSQLPackages(self,term,exact_match,bit_flag,page_number):
159159
rows = ()
160160
LOGGER.debug(f"We have {len(tables)} tables")
161161
for table in tables:
162-
if exact_match==True:
162+
if exact_match:
163163
LOGGER.debug("Exact Match")
164164
query = f"SELECT packageName,description,version,osName FROM {table} where packageName = %s"
165165
else:

src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def searchPackages():
4444
try:
4545
search_term = str(request.args.get('search_term', ''))
4646
search_term = search_term.lstrip().rstrip()
47-
exact_match = request.args.get('exact_match', False)
47+
exact_match = request.args.get('exact_match', 'false').lower() == 'true'
4848
search_bit_flag = int(request.args.get('search_bit_flag', '0'))
4949
page_number = int(request.args.get('page_number', '0'))
5050

0 commit comments

Comments
 (0)