Skip to content

Commit

Permalink
Fix failing OracleDBTests
Browse files Browse the repository at this point in the history
  • Loading branch information
blairmcg committed Nov 3, 2024
1 parent eb59b2f commit a627a51
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,14 @@ testQueryAndUpdateBlob
self assert: field isKindOf: DBLongVarField.
self assert: field fieldBuf isKindOf: DBVarBinaryBuffer.
originalPicture := field value.
self assert: originalPicture isKindOf: ByteArray.
self assert: (originalPicture isNil or: [originalPicture isKindOf: ByteArray]).
updateStatement := 'UPDATE Categories SET Picture=? WHERE CategoryID=?'.
update := connection prepare: updateStatement.
dbResources add: update.
update paramCols: resultSet describeCols.
picture := (Graphics.Bitmap fromFile: 'Resources\Beach ball.bmp' usingLocator: FileLocator installRelative)
asByteArray.
update values: {picture. 1}.
picture := (Graphics.Bitmap fromFile: 'Resources\Beach ball.bmp'
usingLocator: FileLocator installRelative) asByteArray.
update values: { picture. 1 }.
update exec.
resultSet := connection query: selectStatement.
dbResources add: resultSet.
Expand All @@ -348,7 +348,7 @@ testQueryAndUpdateBlob
resultSet free.
self assert: pic2 equals: picture].
"Reset"
update values: {originalPicture. 1}.
update values: { originalPicture. 1 }.
update exec.
resultSet := connection query: selectStatement.
dbResources add: resultSet.
Expand Down Expand Up @@ -512,7 +512,6 @@ testUpdateBlobSetNull
dbResources add: resultSet.
row := resultSet single.
originalPicture := resultSet buffer contents first value.
self denyIsNil: originalPicture.
updateStatement := 'UPDATE Categories SET Picture=? WHERE CategoryID=?'.
update := connection prepare: updateStatement.
dbResources add: update.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,33 @@ Database.Tests.DBConnectionTestResource comment: ''!

!Database.Tests.DBConnectionTestResource methodsFor!

canConnect
| cnxn |
cnxn := self createConnection.
^[cnxn notNil] ensure: [cnxn close]!

basicConnection
^(DBConnection new connectString: self connectString)
useDriverCompletion: false;
open;
yourself!

canConnect
| cnxn |
cnxn := self createConnection.
^[cnxn notNil] ensure: [cnxn close]!

connect
connection := self newConnection!

connection
^connection ifNil: [connection := self newConnection]!

connectionStringAttributes
| keyValuePairs |
keyValuePairs := Dictionary
withAll: (($; split: self connectString) collect:
[:each |
| keyValuePair |
keyValuePair := $= split: each.
keyValuePair first asUppercase -> keyValuePair second]).
^keyValuePairs!

connectString
self subclassResponsibility!

Expand Down Expand Up @@ -102,9 +112,12 @@ tearDown

!Database.Tests.DBConnectionTestResource categoriesForMethods!
basicConnection!helpers!private! !
canConnect!public!testing! !
connect!helpers!private! !
connection!accessing!private! !
connectionStringAttributes!constants!private! !
connectString!accessing!private! !
createConnection!operations!public! !
createDatabase!operations!private! !
dropDatabase!helpers!private! !
execSqlCmd:stdin:!helpers!private! !
Expand Down
11 changes: 11 additions & 0 deletions Core/Object Arts/Dolphin/Database/Database.Tests.OracleDBTest.cls
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,21 @@ Database.Tests.OracleDBTest comment: ''!

!Database.Tests.OracleDBTest methodsFor!

categoriesColumns
^{{'CATEGORYID'. SQL_DECIMAL. 10. 0. 13}.
{'CATEGORYNAME'. SQL_WVARCHAR. 15. nil. 30}.
{'DESCRIPTION'. SQL_WLONGVARCHAR. 16r7FFFFFFF. nil. 16r7FFFFFFF}.
{'PICTURE'. SQL_LONGVARBINARY. 16r7FFFFFFF. nil. 16r7FFFFFFF}}!

databaseName
^''!

databaseResource
^OracleNorthwindDB current!

dataSourceName
^OracleNorthwindDB current connectionStringAttributes at: 'DSN'!

defaultCursorCommitBehavior
^SQL_CB_PRESERVE!

Expand Down Expand Up @@ -92,8 +101,10 @@ self skip. "Oracle's ODBC driver still doesn't support INTERVALs..."
! !

!Database.Tests.OracleDBTest categoriesForMethods!
categoriesColumns!constants!private! !
databaseName!constants!private! !
databaseResource!accessing!private! !
dataSourceName!constants!private! !
defaultCursorCommitBehavior!constants!private! !
defaultCursorRollbackBehaviour!constants!private! !
field:fromRow:!helpers!private! !
Expand Down

0 comments on commit a627a51

Please sign in to comment.