System.Data.SQLite
Check-in [2185ed4885]
Not logged in

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

Overview
Comment:Slightly simplify tests by centralizing code that creates raw changeset data from a session.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sessions
Files: files | file ages | folders
SHA1: 2185ed4885de396bc1ec08197a92dcfb3692f44c
User & Date: mistachkin 2017-10-11 04:39:36
Context
2017-10-11
04:53
Update version history docs. check-in: 9706984ee1 user: mistachkin tags: sessions
04:39
Slightly simplify tests by centralizing code that creates raw changeset data from a session. check-in: 2185ed4885 user: mistachkin tags: sessions
04:03
Add test for the ISQLiteChangeSet.Invert method. check-in: 53b6aee403 user: mistachkin tags: sessions
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Tests/session.eagle.

86
87
88
89
90
91
92
















93
94
95
96
97
98
99
...
130
131
132
133
134
135
136
137
138
139
140
141

142
143

144
145
146
147
148
149
150
...
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
...
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
...
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
...
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
...
584
585
586
587
588
589
590

591
592
593
594
595
596
597
598
    return [object invoke -flags +NonPublic \
        System.Data.SQLite.HelperMethods ToDisplayString $value]
  }
}

###############################################################################

















proc changeSetToString { changeSet includeValues } {
  set result [list]

  if {[isObjectHandle $changeSet] && $changeSet ne "null"} then {
    object foreach -alias item $changeSet {
      lappend result TableName [$item TableName]
      lappend result NumberOfColumns [$item NumberOfColumns]
................................................................................
}

###############################################################################

proc matchSession { connection session expr } {
  if {[isObjectHandle $session] && $session ne "null"} then {
    if {![$session IsEmpty]} then {
      unset -nocomplain byteArray; set byteArray null
      $session -alias CreateChangeSet byteArray
      set rawData [createByteArray [arrayToList byteArray]]
      object removeref $rawData


      return [matchChangeSet [set changeSet \
          [$connection -alias CreateChangeSet $rawData]] $expr]

    }
  }

  return false
}

###############################################################################
................................................................................
  set connection [getDbConnection]

  set session [$connection -alias CreateSession main]
  $session AttachTable null

  makeSomeChanges $db t1 [list insert update delete] true

  unset -nocomplain byteArray; set byteArray null
  $session -alias CreateChangeSet byteArray
  set rawData [createByteArray [arrayToList byteArray]]
  object removeref $rawData

  set stream(1) [object create -alias \
      System.IO.FileStream $fileName(1) Create Write]

  $stream(1) Write $rawData 0 [$rawData Length]
  $stream(1) Flush; $stream(1) Close
................................................................................
  set connection [getDbConnection]

  set session [$connection -alias CreateSession main]
  $session AttachTable null

  makeSomeChanges $db t1 [list insert update delete] false

  unset -nocomplain byteArray; set byteArray null
  $session -alias CreateChangeSet byteArray
  set rawData [createByteArray [arrayToList byteArray]]
  object removeref $rawData

  set changeSet(1) [$connection -alias CreateChangeSet $rawData]
  set changeSet(2) [$changeSet(1) -alias Invert]

  list [changeSetToString $changeSet(1) true] \
      [changeSetToString $changeSet(2) true]
................................................................................

  $session SetToDisabled
  lappend result IsEnabled [$session IsEnabled]

  makeSomeChanges $db t1 [list insert] false
  lappend result IsEmpty [$session IsEmpty]

  unset -nocomplain byteArray; set byteArray null
  $session -alias CreateChangeSet byteArray
  set rawData [createByteArray [arrayToList byteArray]]
  object removeref $rawData

  lappend result Length [$rawData Length]

  $session SetToEnabled
  lappend result IsEnabled [$session IsEnabled]

  makeSomeChanges $db t1 [list insert] false
  lappend result IsEmpty [$session IsEmpty]

  unset -nocomplain byteArray; set byteArray null
  $session -alias CreateChangeSet byteArray
  set rawData [createByteArray [arrayToList byteArray]]
  object removeref $rawData

  set changeSet(1) [$connection -alias CreateChangeSet $rawData]
  lappend result [changeSetToString $changeSet(1) false]
} -cleanup {
  cleanupSomeText

................................................................................

  $session SetToIndirect
  lappend result IsIndirect [$session IsIndirect]

  makeSomeChanges $db t1 [list insert] false
  lappend result IsEmpty [$session IsEmpty]

  unset -nocomplain byteArray; set byteArray null
  $session -alias CreateChangeSet byteArray
  set rawData [createByteArray [arrayToList byteArray]]
  object removeref $rawData

  $session SetToDirect
  lappend result IsIndirect [$session IsIndirect]

  makeSomeChanges $db t1 [list insert] false
  lappend result IsEmpty [$session IsEmpty]

  unset -nocomplain byteArray; set byteArray null
  $session -alias CreateChangeSet byteArray
  set rawData [createByteArray [arrayToList byteArray]]
  object removeref $rawData

  set changeSet(1) [$connection -alias CreateChangeSet $rawData]
  lappend result [changeSetToString $changeSet(1) false]
} -cleanup {
  cleanupSomeText

................................................................................
rename arrayToList ""
rename getChangeSetFileName ""
rename makeSomeChanges ""
rename createTheSchema ""
rename matchChangeSet ""
rename matchSession ""
rename changeSetToString ""

rename forDisplay ""
rename cleanupSomeText ""
rename getSomeText ""

###############################################################################

runSQLiteTestEpilogue
runTestEpilogue







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







<
<
|


>
|
|
>







 







<
<
|







 







<
<
|







 







<
<
|










<
<
|







 







<
<
|








<
<
|







 







>








86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
...
146
147
148
149
150
151
152


153
154
155
156
157
158
159
160
161
162
163
164
165
166
...
277
278
279
280
281
282
283


284
285
286
287
288
289
290
291
...
331
332
333
334
335
336
337


338
339
340
341
342
343
344
345
...
410
411
412
413
414
415
416


417
418
419
420
421
422
423
424
425
426
427


428
429
430
431
432
433
434
435
...
469
470
471
472
473
474
475


476
477
478
479
480
481
482
483
484


485
486
487
488
489
490
491
492
...
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
    return [object invoke -flags +NonPublic \
        System.Data.SQLite.HelperMethods ToDisplayString $value]
  }
}

###############################################################################

proc createChangeSetForSession { session } {
  if {[isObjectHandle $session] && $session ne "null"} then {
    set byteArray null
    $session -alias CreateChangeSet byteArray

    set rawData [createByteArray [arrayToList byteArray]]
    object removeref $rawData

    return $rawData
  }

  return null
}

###############################################################################

proc changeSetToString { changeSet includeValues } {
  set result [list]

  if {[isObjectHandle $changeSet] && $changeSet ne "null"} then {
    object foreach -alias item $changeSet {
      lappend result TableName [$item TableName]
      lappend result NumberOfColumns [$item NumberOfColumns]
................................................................................
}

###############################################################################

proc matchSession { connection session expr } {
  if {[isObjectHandle $session] && $session ne "null"} then {
    if {![$session IsEmpty]} then {


      set rawData [createChangeSetForSession $session]
      object removeref $rawData

      if {[isObjectHandle $rawData] && $rawData ne "null"} then {
        return [matchChangeSet [set changeSet \
            [$connection -alias CreateChangeSet $rawData]] $expr]
      }
    }
  }

  return false
}

###############################################################################
................................................................................
  set connection [getDbConnection]

  set session [$connection -alias CreateSession main]
  $session AttachTable null

  makeSomeChanges $db t1 [list insert update delete] true



  set rawData [createChangeSetForSession $session]
  object removeref $rawData

  set stream(1) [object create -alias \
      System.IO.FileStream $fileName(1) Create Write]

  $stream(1) Write $rawData 0 [$rawData Length]
  $stream(1) Flush; $stream(1) Close
................................................................................
  set connection [getDbConnection]

  set session [$connection -alias CreateSession main]
  $session AttachTable null

  makeSomeChanges $db t1 [list insert update delete] false



  set rawData [createChangeSetForSession $session]
  object removeref $rawData

  set changeSet(1) [$connection -alias CreateChangeSet $rawData]
  set changeSet(2) [$changeSet(1) -alias Invert]

  list [changeSetToString $changeSet(1) true] \
      [changeSetToString $changeSet(2) true]
................................................................................

  $session SetToDisabled
  lappend result IsEnabled [$session IsEnabled]

  makeSomeChanges $db t1 [list insert] false
  lappend result IsEmpty [$session IsEmpty]



  set rawData [createChangeSetForSession $session]
  object removeref $rawData

  lappend result Length [$rawData Length]

  $session SetToEnabled
  lappend result IsEnabled [$session IsEnabled]

  makeSomeChanges $db t1 [list insert] false
  lappend result IsEmpty [$session IsEmpty]



  set rawData [createChangeSetForSession $session]
  object removeref $rawData

  set changeSet(1) [$connection -alias CreateChangeSet $rawData]
  lappend result [changeSetToString $changeSet(1) false]
} -cleanup {
  cleanupSomeText

................................................................................

  $session SetToIndirect
  lappend result IsIndirect [$session IsIndirect]

  makeSomeChanges $db t1 [list insert] false
  lappend result IsEmpty [$session IsEmpty]



  set rawData [createChangeSetForSession $session]
  object removeref $rawData

  $session SetToDirect
  lappend result IsIndirect [$session IsIndirect]

  makeSomeChanges $db t1 [list insert] false
  lappend result IsEmpty [$session IsEmpty]



  set rawData [createChangeSetForSession $session]
  object removeref $rawData

  set changeSet(1) [$connection -alias CreateChangeSet $rawData]
  lappend result [changeSetToString $changeSet(1) false]
} -cleanup {
  cleanupSomeText

................................................................................
rename arrayToList ""
rename getChangeSetFileName ""
rename makeSomeChanges ""
rename createTheSchema ""
rename matchChangeSet ""
rename matchSession ""
rename changeSetToString ""
rename createChangeSetForSession ""
rename forDisplay ""
rename cleanupSomeText ""
rename getSomeText ""

###############################################################################

runSQLiteTestEpilogue
runTestEpilogue