_xotcl-core__test_prepared_statements (private)

 _xotcl-core__test_prepared_statements

Defined in packages/xotcl-core/tcl/test/xotcl-test-procs.tcl

Partial Call Graph (max 5 caller/called nodes):
%3 aa_equals aa_equals (public) aa_false aa_false (public) aa_log aa_log (public) aa_log_result aa_log_result (public) template::multirow template::multirow (public) _xotcl-core__test_prepared_statements _xotcl-core__test_prepared_statements _xotcl-core__test_prepared_statements->aa_equals _xotcl-core__test_prepared_statements->aa_false _xotcl-core__test_prepared_statements->aa_log _xotcl-core__test_prepared_statements->aa_log_result _xotcl-core__test_prepared_statements->template::multirow

Testcases:
No testcase defined.
Source code:
        
        set _aa_export {}
        set body_count 1
        foreach testcase_body {{
    #
    # get_value
    #

    aa_false "::xo::dc get_value with 0 parameters, unprepared statement - no error" [catch {
        set object_id [::xo::dc get_value one_object {select max(object_id) from acs_objects}]
    }]

    aa_false "::xo::dc get_value with 0 parameters, prepared statement - no error" [catch {
        set object_id [::xo::dc get_value -prepare "" one_object {
            select max(object_id) from acs_objects
        }]
    }]

    #
    # 1row
    #

    aa_false "::xo::dc 1row with 1 parameter, unprepared statement - no error" [catch {
        ::xo::dc 1row get_object {
            select object_id as object_id_found_1
            from acs_objects where object_id = :object_id
        }
    }]

    aa_equals "::xo::dc 1row with 1 parameter, unprepared statement - value was returned"  $object_id $object_id_found_1

    aa_false "::xo::dc 1row with 1 parameter, prepared statement" [catch {
        ::xo::dc 1row -prepare integer get_object {
            select object_id as object_id_found_2
            from acs_objects where object_id = :object_id
        }
    }]

    aa_equals "::xo::dc 1row with 1 parameter, prepared statement - value was returned"  $object_id $object_id_found_2

    aa_false "::xo::dc 1row with 2 parameters, unprepared statement - no error" [catch {
        ::xo::dc 1row get_object {
            select object_id as object_id_found_3
            from acs_objects where object_id = :object_id and object_id = :object_id
        }
    }]

    aa_equals "::xo::dc 1row with 2 parameters, unprepared statement - value was returned"  $object_id $object_id_found_3

    aa_false "::xo::dc 1row with 2 parameters, prepared statement" [catch {
        ::xo::dc 1row -prepare integer,integer get_object {
            select object_id as object_id_found_4
            from acs_objects where object_id = :object_id and object_id = :object_id
        }
    }]

    if {[info procs ns_pg_prepare] ne ""} {

        #
        # ns_pg_prepare is implemented via tcl fallback: this
        # NaviServer version will not support prepared statements
        # where the query contains strings with colon.
        #
        set aa_error_level $::aa_error_level
        set ::aa_error_level warning
        aa_log_result fail "This NaviServer version does not support prepared statements with strings containing colons."
        set ::aa_error_level $aa_error_level

    } else {

        aa_false "::xo::dc 1row with 1 parameter, prepared statement with SQL containing colon - no error" [catch {
            ::xo::dc 1row -prepare integer get_object {
                select object_id as object_id_found_6
                from acs_objects where object_id = :object_id and title <> '__I:Do:Not:Exist'
            }
        }]

        aa_equals "::xo::dc 1row with 1 parameter, prepared statement with SQL containing colon - value was returned"  $object_id $object_id_found_6

        aa_false "::xo::dc 1row with 1 parameter, prepared statement with SQL containing colon - no error" [catch {
            ::xo::dc 1row -prepare integer get_object {
                select object_id as object_id_found_7
                from acs_objects
                where object_id = :object_id
                and title <> ':__I:Do:Not:Exist'
                and title <> ' :__I::also:Do:Not:Exist'
            }
        }]

        aa_equals "::xo::dc 1row with 1 parameter, prepared statement with SQL containing colon - value was returned"  $object_id $object_id_found_7

    }

    #
    # foreach
    #

    aa_false "::xo::dc foreach with 1 parameter - no error" [catch {
        set l [list]
        ::xo::dc foreach get_object {
            select object_id as object_id_found_8
            from acs_objects
           where object_id = :object_id
        } {
            lappend l $object_id_found_8
        }
    }]

    aa_equals "::xo::dc foreach with 1 parameter - value was returned"  $l [list $object_id]

    aa_false "::xo::dc foreach with 1 parameter, prepared statement - no error" [catch {
        set l2 [list]
        ::xo::dc foreach -prepare integer get_object {
            select object_id as object_id_found_9
            from acs_objects
           where object_id = :object_id
        } {
            lappend l2 $object_id_found_9
        }
    }]

    aa_equals "::xo::dc foreach with 1 parameter, prepared statement - value was returned"  $l2 [list $object_id]

    #
    # multirow
    #

    aa_false "::xo::dc multirow with 1 parameter - no error" [catch {
        set l3 [list]
        ::xo::dc multirow test get_object {
            select object_id as object_id_found_10
            from acs_objects
           where object_id = :object_id
        } {
            lappend l3 $object_id_found_10
        }
    }]

    aa_equals "::xo::dc multirow with 1 parameter - value was returned"  $l3 [list $object_id]

    aa_false "::xo::dc multirow with 1 parameter, prepared statement - no error" [catch {
        ::xo::dc multirow -prepare integer test get_object {
            select object_id + 1 as object_id_found_10
            from acs_objects
           where object_id = :object_id
        } {
            lappend l3 $object_id_found_10
        }
    }]

    aa_equals "::xo::dc multirow with 1 parameter, prepared statement - value was returned"  $l3 [list $object_id [expr {$object_id + 1}]]

    aa_equals "::xo::dc multirow appended twice to the test multirow"  [::template::multirow size test] 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_prepared_statements (body $body_count): Error during execution: $msg, stack trace: \n$::errorInfo"
          }
          incr body_count
        }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: