updated test cases and added or condition
This commit is contained in:
parent
bb440a068f
commit
135b9b7202
18
queryTest.py
18
queryTest.py
@ -7,17 +7,28 @@ with open('test.json') as f:
|
|||||||
for element in data:
|
for element in data:
|
||||||
for key, value in element.items():
|
for key, value in element.items():
|
||||||
title=key
|
title=key
|
||||||
print("Search Title: " + title)
|
# print("Search Title: " + title)
|
||||||
query="SELECT * FROM COMICS where "
|
query="SELECT * FROM COMICS where "
|
||||||
for i in value:
|
for i in value:
|
||||||
first=True
|
first=True
|
||||||
for j,k in i.items():
|
for j,k in i.items():
|
||||||
if k != '':
|
if k != '':
|
||||||
print(j,k)
|
# print(j,k)
|
||||||
if not first:
|
if not first:
|
||||||
query = query + "and "
|
query = query + "and "
|
||||||
if type(k) == list:
|
if type(k) == list:
|
||||||
print(k)
|
# print(k)
|
||||||
|
if j == "series" or j == "title":
|
||||||
|
firstS = True
|
||||||
|
query = query + "("
|
||||||
|
for l in k:
|
||||||
|
if not firstS:
|
||||||
|
query = query + "or "
|
||||||
|
query = query + j + " like '%" + l + "%' "
|
||||||
|
if firstS:
|
||||||
|
firstS = False
|
||||||
|
query = query + ") "
|
||||||
|
else:
|
||||||
query = query + j + " in ("
|
query = query + j + " in ("
|
||||||
firstL = True
|
firstL = True
|
||||||
for l in k:
|
for l in k:
|
||||||
@ -27,6 +38,7 @@ for element in data:
|
|||||||
if firstL:
|
if firstL:
|
||||||
firstL = False
|
firstL = False
|
||||||
query = query + ") "
|
query = query + ") "
|
||||||
|
|
||||||
else:
|
else:
|
||||||
query = query + j + " like '%" + k + "%' "
|
query = query + j + " like '%" + k + "%' "
|
||||||
if first:
|
if first:
|
||||||
|
13
test.json
13
test.json
@ -13,10 +13,21 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"Marvel": [
|
||||||
|
{
|
||||||
|
"title": "",
|
||||||
|
"volume": "",
|
||||||
|
"publisher": "marvel",
|
||||||
|
"series": "",
|
||||||
|
"issue": ""
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"Girl": [
|
"Girl": [
|
||||||
{
|
{
|
||||||
"title": "girl",
|
"title": ["girl","man","World"],
|
||||||
"volume": "",
|
"volume": "",
|
||||||
"publisher": "",
|
"publisher": "",
|
||||||
"series": "girl",
|
"series": "girl",
|
||||||
|
Loading…
Reference in New Issue
Block a user