_xotcl-core__test_multirow (private)
_xotcl-core__test_multirow
Defined in packages/xotcl-core/tcl/test/xotcl-test-procs.tcl
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: set _aa_export {} set body_count 1 foreach testcase_body {{ aa_section "Test that ::xo::dc multirow behaves as db_multirow with respect to Bug 3441" # # Create a multirow with 0 entries and append a row "manually" # For details, see # https://openacs.org/bugtracker/openacs/bug?bug_number=3441 # ::xo::dc multirow __xotcl_person_mr1 noxql { SELECT person_id, first_names, last_name FROM persons WHERE false } aa_equals "have empty multirow" [template::multirow size __xotcl_person_mr1] 0 template::multirow append __xotcl_person_mr1 1234 “Ed” “Grooberman” aa_equals "have one tuple in multirow" [template::multirow size __xotcl_person_mr1] 1 aa_equals "columns empty" [template::multirow columns __xotcl_person_mr1] "person_id first_names last_name" set user_id [ad_conn user_id] ::xo::dc multirow person_mr2 noxql { SELECT person_id, first_names, last_name FROM persons where person_id = :user_id } aa_equals "columns nonempty" [template::multirow columns person_mr2] "person_id first_names last_name" aa_section "Create a new multirow via ::xo::dc, then append via the ::template api" # We set d outside the multirow body to show that the variable # will be reinitialized at every loop. set d a ::xo::dc multirow -local t -extend {d e} __test_multirow q { select * from (values (1, 2, 3), (4, 5, 6), (7, 8, 9), (10, 11, 12), (666, 666, 666)) as t (a, b, c) } { # Test issuing continue in the loop if {$a == 7} { continue } # Test issuing break in the loop if {$c == 12} { break } # Test changing a "native" column incr a # Test changing an extended column (var existed outside) append d a } aa_equals "columns nonempty" [template::multirow -local columns __test_multirow] {a b c d e} aa_equals "size is 2" [template::multirow -local size __test_multirow] 2 set template { <ul> <multiple name="__test_multirow"> <li> |@__test_multirow.a@| @__test_multirow.b@| @__test_multirow.c@| @__test_multirow.d@| @__test_multirow.e@ </li> </multiple> </ul> } set code [template::adp_compile -string $template] set expected { <ul> <li>|2|2|3|a|</li> <li>|5|5|6|a|</li> </ul> } aa_equals "Template returns expected result" [join [template::adp_eval code] ""] [join $expected ""] template::multirow -local append __test_multirow I am appended to multirow set expected { <ul> <li>|2|2|3|a|</li> <li>|5|5|6|a|</li> <li>|I|am|appended|to|multirow</li> </ul> } aa_equals "Template returns expected result after appending to the multirow" [join [template::adp_eval code] ""] [join $expected ""] aa_section "Create a multirow via the ::template api, then append via the ::xo::dc interface" template::multirow -local create __test_multirow_2 a b c template::multirow -local append __test_multirow_2 1 2 3 ::xo::dc multirow -local t __test_multirow_2 q { select * from (values (4, 5, 6), (7, 8, 9)) as t (a, b, c) } aa_equals "size is 3" [template::multirow -local size __test_multirow_2] 3 aa_section "Append again via ::xo::dc" ::xo::dc multirow -extend {b c} -local t __test_multirow_2 q { select * from (values (10), (13)) as t (a) } { set b [expr {$a + 1}] set c [expr {$b + 1}] } aa_equals "size is 5" [template::multirow -local size __test_multirow_2] 5 set template { <ul> <multiple name="__test_multirow_2"> <li> |@__test_multirow_2.a@| @__test_multirow_2.b@| @__test_multirow_2.c@| </li> </multiple> </ul> } set code [template::adp_compile -string $template] set expected { <ul> <li>|1|2|3|</li> <li>|4|5|6|</li> <li>|7|8|9|</li> <li>|10|11|12|</li> <li>|13|14|15|</li> </ul> } aa_equals "Template returns expected result after appending to the multirow" [join [template::adp_eval code] ""] [join $expected ""] aa_section "Multirows with a numeric value ending in '.'" ::xo::dc multirow -local t __test_multirow_dot_1 q { select * from (values ('2.')) as t(a) } ::template::multirow -local foreach __test_multirow_dot_1 { aa_equals "Value is correct when looping through __test_multirow_dot_1 later" $a "2." } ::xo::dc multirow -local t __test_multirow_dot_2 q { select * from (values ('2.')) as t(a) } { aa_equals "Value is correct in __test_multirow_dot_2 body" $a "2." } ::template::multirow -local foreach __test_multirow_dot_2 { aa_equals "Value is correct when looping through __test_multirow_dot_2 later" $a "2." } }} { aa_log "Running testcase body $body_count" set ::__aa_test_indent [info level] set catch_val [catch $testcase_body msg] if {$catch_val != 0 && $catch_val != 2} { aa_log_result "fail" "test_multirow (body $body_count): Error during execution: $msg, stack trace: \n$::errorInfo" } incr body_count }XQL Not present: Generic, PostgreSQL, Oracle