Index: openacs-4/packages/acs-service-contract/tcl/contract-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-service-contract/tcl/contract-procs.tcl,v diff -u -r1.13 -r1.13.2.1 --- openacs-4/packages/acs-service-contract/tcl/contract-procs.tcl 17 Jun 2018 19:20:09 -0000 1.13 +++ openacs-4/packages/acs-service-contract/tcl/contract-procs.tcl 2 Jan 2020 18:04:58 -0000 1.13.2.1 @@ -150,17 +150,31 @@ db_transaction { # Need both name and ID below if { $name eq "" } { - set name [db_string get_name_by_id {}] + set name [db_string get_name_by_id { + select contract_name + from acs_sc_contracts + where contract_id = :contract_id + }] } elseif { $contract_id eq "" } { - set contract_id [db_string get_id_by_name {}] + set contract_id [db_string get_id_by_name { + select contract_id + from acs_sc_contracts + where contract_name = :contract_name + }] } if { !$no_cascade_p } { set operations [list] set msg_types [list] - db_foreach select_operations {} { + db_foreach select_operations { + select operation_id, + operation_inputtype_id, + operation_outputtype_id + from acs_sc_operations + where contract_id = :contract_id + } { # Put them on list of message types and operations to delete lappend msg_types $operation_inputtype_id lappend msg_types $operation_outputtype_id @@ -180,10 +194,10 @@ } } - # LARS: - # It seems like delete by ID doesn't work, because our PG bind thing turns all integers into strings - # by wrapping them in single quotes, causing PG to invoke the function for deleting by name - db_exec_plsql delete_by_name {} + db_dml delete_contract { + delete from acs_sc_contracts + where contract_id = :contract_id + } } } @@ -192,7 +206,13 @@ } { Get a list of names of operations for the contract. } { - return [db_list select_operations {}] + return [db_list select_operations { + select o.operation_name + from acs_sc_operations o, + acs_sc_contracts c + where c.contract_name = :contract_name + and o.contract_id = c.contract_id + }] } @@ -254,16 +274,19 @@ error "You must supply either contract_name and operation_name, or operation_id" } - # LARS: - # It seems like delete by ID doesn't work, because our PG bind thing turns all integers into strings - # by wrapping them in single quotes, causing PG to invoke the function for deleting by name - - if { $contract_name eq "" || $operation_name eq "" } { - # get contract_name and operation_name - db_1row select_names {} + if {$operation_id eq ""} { + set operation_id [db_string get_id { + select operation_id + from acs_sc_operations + where contract_name = :contract_name + and operation_name = :operation_name + }] } - db_exec_plsql delete_by_name {} + db_dml delete_operation { + delete from acs_sc_operations + where operation_id = :operation_id + } } ad_proc -public acs_sc::contract::operation::parse_operations_spec {