Index: openacs-4/packages/acs-tcl/tcl/test/acs-tcl-test-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/test/acs-tcl-test-procs.tcl,v diff -u -N -r1.71 -r1.71.2.1 --- openacs-4/packages/acs-tcl/tcl/test/acs-tcl-test-procs.tcl 10 Dec 2018 14:47:25 -0000 1.71 +++ openacs-4/packages/acs-tcl/tcl/test/acs-tcl-test-procs.tcl 18 Feb 2019 12:40:09 -0000 1.71.2.1 @@ -1088,6 +1088,41 @@ } +aa_register_case \ + -cats {db smoke production_safe} \ + -procs {db_foreach} \ + db__db_foreach { + Checks that db_foreach works as expected + } { + set results [list] + db_foreach query {SELECT a FROM (VALUES (1), (2), (3), (4), (5), (6), (7)) AS X(a)} { + lappend results $a + } + aa_equals "db_foreach collects correct values from query" \ + [list 1 2 3 4 5 6 7] \ + $results + + set results "" + db_foreach query {select 1 from dual where 1 = 2} { + set results "found" + } else { + set results "not found" + } + aa_equals "db_foreach executes the 'no row' code block using the 'else' syntax" \ + "not found" \ + $results + + set results "" + db_foreach query {select 1 from dual where 1 = 2} { + set results "found" + } if_no_rows { + set results "not found" + } + aa_equals "db_foreach executes the 'no row' code block using the 'if_no_rows' syntax" \ + "not found" \ + $results + } + aa_register_case -cats {api db} db__caching { test db_* API caching } {