@@ -998,7 +998,9 @@ def requery(
998
998
not len (self .frm [parent_table ].rows .index )
999
999
or Relationship .parent_virtual (self .table , self .frm )
1000
1000
):
1001
- self .rows = pd .DataFrame (columns = self .rows .columns ) # purge rows
1001
+ # purge rows
1002
+ self .rows = Result .set (pd .DataFrame (columns = self .rows .columns ))
1003
+
1002
1004
if update_elements :
1003
1005
self .frm .update_elements (self .key )
1004
1006
if requery_dependents :
@@ -2369,13 +2371,22 @@ def insert_row(self, row: dict, idx: int = None) -> None:
2369
2371
:returns: None
2370
2372
"""
2371
2373
row_series = pd .Series (row )
2372
- attrs = self .rows .attrs .copy ()
2373
- self .rows = pd .concat ([self .rows , row_series .to_frame ().T ], ignore_index = True )
2374
- self .rows .attrs = attrs
2374
+ if self .rows .empty :
2375
+ self .rows = Result .set (
2376
+ pd .concat ([self .rows , row_series .to_frame ().T ], ignore_index = True )
2377
+ )
2378
+ else :
2379
+ attrs = self .rows .attrs .copy ()
2380
+
2381
+ # TODO: idx currently does nothing
2382
+ if idx is None :
2383
+ idx = len (self .rows .index )
2384
+
2385
+ self .rows = pd .concat (
2386
+ [self .rows , row_series .to_frame ().T ], ignore_index = True
2387
+ )
2388
+ self .rows .attrs = attrs
2375
2389
2376
- # I don't have the idx parameter working yet
2377
- if idx is None :
2378
- idx = len (self .rows .index )
2379
2390
idx_label = self .rows .index .max () if len (self .rows .index ) > 0 else 0
2380
2391
self .rows .attrs ["virtual" ].loc [idx_label ] = 1 # True, series only holds int64
2381
2392
0 commit comments