System.Data.SQLite
Check-in [cd91b8e6bf]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Enhance the 'getRowsFromDataTable' test suite helper procedure.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: cd91b8e6bff0c634ec1576934435e38882a5e0e2
User & Date: mistachkin 2016-10-10 20:48:53
Context
2016-10-13
17:31
Update SQLite core library to the latest trunk. check-in: 1da3d937ca user: mistachkin tags: trunk
2016-10-10
20:58
Add initial test cases for ticket [01f20ea55a]. check-in: 5d35df2f75 user: mistachkin tags: tkt-01f20ea55a
20:48
Enhance the 'getRowsFromDataTable' test suite helper procedure. check-in: cd91b8e6bf user: mistachkin tags: trunk
2016-10-07
19:20
Use NuGet 2.x to build the official NuGet packages for a release. Pursuant to [e9573e2d12]. check-in: bb7d27069f user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to lib/System.Data.SQLite/common.eagle.

  2657   2657         # NOTE: Add the database connection provided by our caller to the list
  2658   2658         #       of those known to the Eagle interpreter.
  2659   2659         #
  2660   2660         object invoke -flags +NonPublic Interpreter.GetActive.connections Add \
  2661   2661             $db $connection
  2662   2662       }
  2663   2663   
  2664         -    proc getRowsFromDataTable { dataTable } {
         2664  +    proc getRowsFromDataTable { dataTable {valueCallback ""} } {
  2665   2665         set rows [list]
  2666   2666         set count [$dataTable Columns.Count]
  2667   2667   
  2668   2668         for {set index 0} {$index < $count} {incr index} {
  2669   2669           set dataColumn [$dataTable -alias Columns.get_Item $index]
  2670   2670           set names($index) [$dataColumn ColumnName]
  2671   2671         }
  2672   2672   
         2673  +      #
         2674  +      # NOTE: Setup some Tcl return code constants.
         2675  +      #
         2676  +      set Ok 0; set Error 1; set Return 2; set Break 3; set Continue 4
         2677  +
  2673   2678         object foreach -alias dataRow [set dataRows [$dataTable Rows]] {
  2674   2679           set row [list]
  2675   2680   
  2676   2681           for {set index 0} {$index < $count} {incr index} {
  2677   2682             set value [$dataRow -create -alias get_Item $index]
  2678   2683   
  2679         -          if {[string length $value] > 0 && \
  2680         -              ![object invoke Convert IsDBNull $value]} then {
  2681         -            lappend row [list $names($index) [$value ToString]]
         2684  +          if {[string length $valueCallback] > 0} then {
         2685  +            set code [catch {
         2686  +              $valueCallback $dataTable $dataRow $index $value
         2687  +            } newValue]
         2688  +
         2689  +            if {$code == $Ok} then {
         2690  +              #
         2691  +              # NOTE: Use the specified (new?) row value.
         2692  +              #
         2693  +              lappend row [list $names($index) $newValue]
         2694  +            } elseif {$code == $Error} then {
         2695  +              #
         2696  +              # NOTE: Use the (new?) NULL row value.
         2697  +              #
         2698  +              lappend row [list $names($index)]
         2699  +            } elseif {$code == $Return} then {
         2700  +              #
         2701  +              # NOTE: Skip remaining values for this row.
         2702  +              #
         2703  +              break
         2704  +            } elseif {$code == $Break} then {
         2705  +              #
         2706  +              # NOTE: Skip processing this row value.
         2707  +              #
         2708  +            } elseif {$code == $Continue} then {
         2709  +              #
         2710  +              # NOTE: Use default row value handling.
         2711  +              #
         2712  +            }
  2682   2713             } else {
  2683         -            lappend row [list $names($index)]
         2714  +            set code $Continue
         2715  +          }
         2716  +
         2717  +          if {$code == $Continue} then {
         2718  +            if {[string length $value] > 0 && \
         2719  +                ![object invoke Convert IsDBNull $value]} then {
         2720  +              lappend row [list $names($index) [$value ToString]]
         2721  +            } else {
         2722  +              lappend row [list $names($index)]
         2723  +            }
  2684   2724             }
  2685   2725           }
  2686   2726   
  2687   2727           lappend rows $row
  2688   2728         }
  2689   2729   
  2690   2730         return $rows