_dirty field not automatically updated
apnadkarni opened this issue · comments
The _dirty field does not seem to get automatically updated when a record is modified. Is it supposed to be manually set ? Documentation implies it only needs to be manually cleared. Also I couldn't see anywhere in the generated code where the field is set implicitly.
Sample:
(ctable) 56 % puts withDirty:$ctable::withDirty
speedtables Testdirty 0.1 {
table Dirty {
varstring s
}
}
package require Testdirty
withDirty:1
(ctable) 60 % Dirty create d
d
(ctable) 61 % d set 0 {s "foo"}
(ctable) 62 % d search -compare {{= _dirty 1}}
0
(ctable) 64 % d get 0 s _dirty
foo 0
(ctable) 65 % d set 0 {s "bar"}
(ctable) 66 % d get 0 s _dirty
bar 0
You're absolutely right. The call to set "_dirty" was inside the body of a switch after the final break. Fixed, tested, and committed.
diff --git a/ctables/gentable.tcl b/ctables/gentable.tcl
index 6db1211..4b9707f 100644
--- a/ctables/gentable.tcl
+++ b/ctables/gentable.tcl
@@ -3851,11 +3851,12 @@ proc gen_set_function {table} {
emit [string range [subst -nobackslashes -nocommands $fieldSetSwitchSource] 1 end-1]
gen_sets
- emit " $rightCurly"
if {$withDirty} {
emit " row->_dirty = 1;"
}
- emit " $rightCurly"
emit " return TCL_OK;"
emit "$rightCurly"
Fixed by above commit.