Skip to content

Commit caa0754

Browse files
committed
refs #281, Record search working again
Searching for records works as expected again
1 parent ccabe70 commit caa0754

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

pysimplesql/pysimplesql.py

+5-17
Original file line numberDiff line numberDiff line change
@@ -1007,13 +1007,8 @@ def requery(
10071007

10081008
rows = self.driver.execute(query)
10091009
self.rows = rows
1010-
1010+
print(self.rows)
10111011
if len(self.rows.index):
1012-
# # if "sort_order" not in self.rows.attrs:
1013-
# # Store the sort order as a dictionary in the attrs of the DataFrame
1014-
# sort_order = self.rows[self.pk_column].to_list()
1015-
# self.rows.attrs["sort_order"] = {self.pk_column: sort_order}
1016-
10171012
# now we can restore the sort order
10181013
self.load_sort_settings(sort_settings)
10191014
self.sort(self.table)
@@ -1254,17 +1249,16 @@ def search(
12541249

12551250
# First lets make a search order.. TODO: remove this hard coded garbage
12561251
if len(self.rows.index):
1257-
logger.debug(f"DEBUG: {self.search_order} {self.rows[0].keys()}")
1258-
for o in self.search_order:
1252+
logger.debug(f"DEBUG: {self.search_order} {self.rows.columns[0]}")
1253+
for field in self.search_order:
12591254
# Perform a search for str, from the current position to the end and back by
12601255
# creating a list of all indexes
12611256
for i in list(range(self.current_index + 1, len(self.rows.index))) + list(
12621257
range(0, self.current_index)
12631258
):
12641259
if (
1265-
o in self.rows[i]
1266-
and self.rows[i][o]
1267-
and search_string.lower() in str(self.rows[i][o]).lower()
1260+
field in list(self.rows.columns)
1261+
and search_string.lower() in str(self.rows.iloc[i][field]).lower()
12681262
):
12691263
old_index = self.current_index
12701264
self.current_index = i
@@ -2336,15 +2330,9 @@ def insert_row(self, row: dict, idx: int = None) -> None:
23362330
if idx is None:
23372331
idx = len(self.rows.index)
23382332
idx_label = self.rows.index.max() if len(self.rows.index) > 0 else 0
2339-
# self.rows.loc[idx_label] = row_series
2340-
# self.rows.attrs["sort_order"][self.pk_column].append(row[self.pk_column])
23412333
self.rows.attrs["virtual"].loc[idx_label] = True
23422334

23432335

2344-
# self.rows.sort_index() (this wasn't doing anything,
2345-
# since it defaults to inplace=False)
2346-
2347-
23482336
class Form:
23492337

23502338
"""

0 commit comments

Comments
 (0)