@@ -1946,7 +1946,7 @@ def duplicate_record(
1946
1946
1947
1947
# Have the driver duplicate the record
1948
1948
result = self .driver .duplicate_record (self , children )
1949
- if result .exception :
1949
+ if result .attrs [ " exception" ] :
1950
1950
self .driver .rollback ()
1951
1951
self .frm .popup .ok (
1952
1952
lang .duplicate_failed_title ,
@@ -1955,7 +1955,7 @@ def duplicate_record(
1955
1955
),
1956
1956
)
1957
1957
else :
1958
- pk = result .lastrowid
1958
+ pk = result .attrs [ " lastrowid" ]
1959
1959
1960
1960
# callback
1961
1961
if "after_duplicate" in self .callbacks :
@@ -2203,6 +2203,7 @@ def sort_by_column(self, column: str, table: str, reverse=False) -> None:
2203
2203
2204
2204
# We don't want to sort by foreign keys directly - we want to sort by the
2205
2205
# description column of the foreign table that the foreign key references
2206
+ tmp_column = None
2206
2207
rels = Relationship .get_relationships (table )
2207
2208
for rel in rels :
2208
2209
if column == rel .fk_column :
@@ -2212,9 +2213,9 @@ def sort_by_column(self, column: str, table: str, reverse=False) -> None:
2212
2213
mapping = dict (zip (df_parent [rel .pk_column ], df_parent [desc_parent ]))
2213
2214
2214
2215
# Create a temporary column in self.rows for the fk data
2215
- tmp = f"temp_{ rel .parent_table } .{ rel .pk_column } "
2216
- self .rows [tmp ] = self .rows [rel .fk_column ].map (mapping )
2217
- column = tmp
2216
+ tmp_column = f"temp_{ rel .parent_table } .{ rel .pk_column } "
2217
+ self .rows [tmp_column ] = self .rows [rel .fk_column ].map (mapping )
2218
+ column = tmp_column
2218
2219
break
2219
2220
try :
2220
2221
self .rows .sort_values (
@@ -2226,7 +2227,8 @@ def sort_by_column(self, column: str, table: str, reverse=False) -> None:
2226
2227
logger .debug (f"DataFrame could not sort by column { column } . KeyError." )
2227
2228
finally :
2228
2229
# Drop the temporary description column (if it exists)
2229
- self .rows .drop (columns = tmp , inplace = True , errors = "ignore" )
2230
+ if tmp_column is not None :
2231
+ self .rows .drop (columns = tmp , inplace = True , errors = "ignore" )
2230
2232
2231
2233
def sort_by_index (self , index : int , table : str , reverse = False ):
2232
2234
"""
@@ -6019,7 +6021,7 @@ class Result:
6019
6021
@classmethod
6020
6022
def set (
6021
6023
cls ,
6022
- row_data : dict ,
6024
+ row_data : dict = None ,
6023
6025
lastrowid : int = None ,
6024
6026
exception : Exception = None ,
6025
6027
column_info : ColumnInfo = None ,
@@ -6465,11 +6467,11 @@ def duplicate_record(self, dataset: DataSet, children: bool) -> pd.DataFrame:
6465
6467
]
6466
6468
for q in query :
6467
6469
res = self .execute (q )
6468
- if res .exception :
6470
+ if res .attrs [ " exception" ] :
6469
6471
return res
6470
6472
6471
6473
# Now we save the new pk
6472
- pk = res .lastrowid
6474
+ pk = res .attrs [ " lastrowid" ]
6473
6475
6474
6476
# create list of which children we have duplicated
6475
6477
child_duplicated = []
0 commit comments