Skip to content

Commit

Permalink
Allow UI DB deletes to be logged
Browse files Browse the repository at this point in the history
  • Loading branch information
yazz committed Jan 30, 2025
1 parent 3a54378 commit cb3b730
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions public/go.html
Original file line number Diff line number Diff line change
Expand Up @@ -14298,7 +14298,9 @@ <h1 style='width:100%;vertical-align:top;display:inline-block;font-size:100px; t
}
alasql("CREATE TRIGGER process" + updateEventTriggerName + " AFTER UPDATE ON " + tableName + " " + updateEventTriggerName);

// note "delete TABLE_NAME" doesn't work.... needs "delete TABLE_NAME where 1=1" to work


// note "delete from TABLE_NAME" doesn't work.... needs "delete from TABLE_NAME where 1=1" to work
let deleteEventTriggerName = "delete_event_table_" + tableName
alasql.fn[deleteEventTriggerName] = async function(r) {
yz.uiDb.uiDbTableData[tableName].data = alasql("select * from " + tableName + " order by id asc")
Expand All @@ -14307,12 +14309,23 @@ <h1 style='width:100%;vertical-align:top;display:inline-block;font-size:100px; t
dbEventType: "DELETE",
value: r
}
if (
[
"ui_table_command_source_file_lines",
"ui_table_debug_trace_log",
"ui_table_debug_sql_log",
"ui_table_command_source_files",
"ui_table_command_source_file_lines",
"ui_table_debug_data_log"
].indexOf(tableName) == -1) {
if (yz.debug.currentSqlLogId) {
//yz.debug.currentSqlLogId = yz.uiDb.sqlui1("select max(id) as id from ui_table_debug_sql_log").id
yz.uiDb.sqlui( "insert into ui_table_debug_data_log ( id , table_name , fk_record_id , operation_type , fk_parent_debug_sql_log_id ) values (?,?,?,?,?)",
[yz.uiDb.uiDbNextId ++,tableName, r.id ,"DELETE",yz.debug.currentSqlLogId])
}
}
}
alasql("CREATE TRIGGER process" + deleteEventTriggerName + " AFTER DELETE ON " + tableName + " " + deleteEventTriggerName);




alasql("CREATE TRIGGER process" + deleteEventTriggerName + " BEFORE DELETE ON " + tableName + " " + deleteEventTriggerName);
},
getUiDbData: function ( { tableName } ) {
return yz.uiDb.uiDbTableData[tableName].data
Expand Down

0 comments on commit cb3b730

Please sign in to comment.