Skip to content

Commit

Permalink
Closes fpco#30
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdone committed Feb 23, 2021
1 parent 635d8b6 commit 7c0cea4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
25 changes: 15 additions & 10 deletions src/Database/ODBC/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -679,16 +679,21 @@ getGuid :: Ptr EnvAndDbc -> SQLHSTMT s -> SQLUSMALLINT -> IO Value
getGuid dbc stmt column = do
uninterruptibleMask_
(do bufferp <- callocBytes odbcGuidBytes
void
(getTypedData
dbc
stmt
sql_c_binary
column
(coerce bufferp)
(SQLLEN odbcGuidBytes))
!bs <- S.unsafePackMallocCStringLen (bufferp, odbcGuidBytes)
evaluate (BinaryValue (Binary bs)))
copiedBytes <-
getTypedData
dbc
stmt
sql_c_binary
column
(coerce bufferp)
(SQLLEN odbcGuidBytes)
case copiedBytes of
Nothing -> do
free bufferp
pure NullValue
Just {} -> do
!bs <- S.unsafePackMallocCStringLen (bufferp, odbcGuidBytes)
evaluate (BinaryValue (Binary bs)))

-- | Get the column's data as a vector of CHAR.
getBytesData :: Ptr EnvAndDbc -> SQLHSTMT s -> SQLUSMALLINT -> IO Value
Expand Down
2 changes: 1 addition & 1 deletion test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ conversionTo = do
quickCheckRoundtrip @ByteString "ByteString" ("varchar(" <> (show maxStringLen) <> ")")
quickCheckRoundtrip @TestBinary "ByteString" ("binary(" <> (show maxStringLen) <> ")")
quickCheckRoundtrip @Binary "ByteString" ("varbinary(" <> (show maxStringLen) <> ")")
quickCheckRoundtripEx @TestGUID False "GUID" "uniqueidentifier"
quickCheckRoundtrip @TestGUID "GUID" "uniqueidentifier" -- Regression tests against https://github.com/fpco/odbc/issues/30

connectivity :: Spec
connectivity = do
Expand Down

0 comments on commit 7c0cea4

Please sign in to comment.