GAFetchTest

GADriverTest subclass: #'GAFetchTest' 

Overview

Please comment me using the following template inspired by Class Responsibility Collaborator (CRC) design:

For the Class part: State the name of the class with one line description: For example, I'm xxx the root of the hierarchy of visitor objects.

For the Responsibility part: Three sentences about my main responsibility, what I'm doing, what services do I offer.

For the Collaborators Part: State my main collaborators and one line about how I interact with them.

Public API and Key Messages

  • label item

One simple example is simply gorgeous.

Internal Representation and Key Implementation Points.

Implementation Points

Instance Method Details

supportsCursoredFetch

supportsCursoredFetch

testPrepareTheCursorTakesOneFetch

testPrepareTheCursorTakesOneFetch
| statement counter resultSet |
self supportsCursoredFetch 
ifFalse: self skip ].

conn beginTransaction
counter := GAFetchCounter new.
statement := conn createStatement: 'SELECT code, name, observations FROM signature'.
statement fetchListener: counter.
statement fetchSize: 20.
resultSet := statement execute.
self assert: counter fetches equals: 1cursor takes one fetch

testReadAllCursoredAtOnceFetchAllAtOnce

testReadAllCursoredAtOnceFetchAllAtOnce
| statement rows counter resultSet |
counter := GAFetchCounter new.
statement := conn createStatement: 'SELECT code, name, observations FROM signature'.
statement fetchListener: counter.
resultSet := statement execute.
rows := resultSet readStream next: 200.
self assert: counter fetches equals: conn numberOfFetchesForSingleExecute

testReadAllFetchInParts

testReadAllFetchInParts
| statement rows counter resultSet |
self supportsCursoredFetch 
ifFalse: self skip ].

conn beginTransaction
counter := GAFetchCounter new.
statement := conn createStatement: 'SELECT code, name, observations FROM signature'.
statement fetchListener: counter.
statement fetchSize: 20.
resultSet := statement execute.
rows := resultSet rows.
self assert: counter fetches equals: 121 execute + 10 times * 20 rows + 1 to know the EOF

testReadInPartsFetchAllAtOnce

testReadInPartsFetchAllAtOnce
| statement rows counter resultSet |
counter := GAFetchCounter new.
statement := conn createStatement: 'SELECT code, name, observations FROM signature'.
statement fetchListener: counter.
resultSet := statement execute.
20 timesRepeat: rows := resultSet readStream next: 10 ].
self assert: counter fetches equals: conn numberOfFetchesForSingleExecute

testReadInPartsFetchInBiggerParts

testReadInPartsFetchInBiggerParts
| statement rows counter readStream |
conn supportsCursoredFetch 
ifFalse: self skip ].

conn beginTransaction
counter := GAFetchCounter new.
statement := conn createStatement: 'SELECT code, name, observations FROM signature'.
statement fetchListener: counter.
statement fetchSize: 20.
readStream := statement execute readStream.
10 timesRepeat: rows := readStream next: 21 ].
self assert: counter fetches equals: 121 create cursor + 10 times * 21 rows + 1 end

testReadInPartsFetchInParts

testReadInPartsFetchInParts
| statement rows counter readStream |
self supportsCursoredFetch 
ifFalse: self skip ].

conn beginTransaction
counter := GAFetchCounter new.
statement := conn createStatement: 'SELECT code, name, observations FROM signature'.
statement fetchListener: counter.
statement fetchSize: 20.
readStream := statement execute readStream.
10 timesRepeat: rows := readStream next: 20 ].
self assert: counter fetches equals: 111 create cursor + 10 times * 20 rows

testReadInPartsFetchInSmallerParts

testReadInPartsFetchInSmallerParts
| statement rows counter readStream |
conn supportsCursoredFetch 
ifFalse: self skip ].

conn beginTransaction
counter := GAFetchCounter new.
statement := conn createStatement: 'SELECT code, name, observations FROM signature'.
statement fetchListener: counter.
statement fetchSize: 20.
readStream := statement execute readStream.
25 timesRepeat: rows := readStream next: 9 ].
self assert: counter fetches equals: 121 create cursor + 10 times * 21 rows + 1 end

testResultIterateResultStreamBigFetchWindow

self debug: #testCursoredResult

testResultIterateResultStreamBigFetchWindow
| select result statement row rows |
self supportsCursoredFetch 
ifFalse: self skip ].

select := 'SELECT code, name, observations FROM signature'.
conn beginTransaction
statement := conn createStatement: select.
statement fetchSize: 100.
result := statement execute readStream.
rows := 0.
row := result next notNil ] whileTrue: 
rows := rows + 1.
self assert: (row at: 1) equals: rows.
self assert: (row at: 2) equals: 'TADP'.
self assert: (row at: 3) equals: 'Tecnicas Av'
 ]
 ]
 ensure: conn rollbackTransaction ].

self assert: rows equals: 200

testResultIterateResultStreamDefaultFetchWindow

self debug: #testCursoredResult

testResultIterateResultStreamDefaultFetchWindow
| select result row rows |
self supportsCursoredFetch 
ifFalse: self skip ].

select := 'SELECT code, name, observations FROM signature'.
result := (conn execute: select) readStream.
rows := 0.
row := result next notNil ] whileTrue: 
rows := rows + 1.
self assert: (row at: 1) equals: rows.
self assert: (row at: 2) equals: 'TADP'.
self assert: (row at: 3) equals: 'Tecnicas Av'
 ]
.

self assert: rows equals: 200

testResultIterateResultStreamReallyBigFetchWindow

self debug: #testCursoredResult

testResultIterateResultStreamReallyBigFetchWindow
| select result statement row rows |
self supportsCursoredFetch 
ifFalse: self skip ].

select := 'SELECT code, name, observations FROM signature'.
conn beginTransaction
statement := conn createStatement: select.
statement fetchSize: 1000.
result := statement execute readStream.
rows := 0.
row := result next notNil ] whileTrue: 
rows := rows + 1.
self assert: (row at: 1) equals: rows.
self assert: (row at: 2) equals: 'TADP'.
self assert: (row at: 3) equals: 'Tecnicas Av'
 ]
 ]
 ensure: conn rollbackTransaction ].

self assert: rows equals: 200

testResultIterateesultStreamSmallFetchWindow

self debug: #testCursoredResult

testResultIterateesultStreamSmallFetchWindow
| select result statement row rows |
self supportsCursoredFetch 
ifFalse: self skip ].

select := 'SELECT code, name, observations FROM signature'.
conn beginTransaction
statement := conn createStatement: select.
statement fetchSize: 10.
result := statement execute readStream.
rows := 0.
row := result next notNil ] whileTrue: 
rows := rows + 1.
self assert: (row at: 1) equals: rows.
self assert: (row at: 2) equals: 'TADP'.
self assert: (row at: 3) equals: 'Tecnicas Av'
 ]
 ]
 ensure: conn rollbackTransaction ].

self assert: rows equals: 200

testTryCursoredFetchFailsIfNotSupported

testTryCursoredFetchFailsIfNotSupported
| statement |
self supportsCursoredFetch 
ifTrue: ^self skip ].

statement := conn createStatement: 'SELECT code, name, observations FROM signature'.
self should: statement fetchSize: 20 ] raise: Error