Skip to content

Commit

Permalink
Added Large objects (LOB) functionality (#51)
Browse files Browse the repository at this point in the history
* Fixed getServerVersion function

* Improved haddock documentation #11

* Pushing haddock coverage to 100%

* Added support for large objects

* Added FromField Instances and removed LOB type

* Applied formolu

* Added withLOB function

* Added haddock documentation for LOB

* Added test cases for LOB
  • Loading branch information
tusharad authored Dec 11, 2024
1 parent f1cd30b commit f9fe17e
Show file tree
Hide file tree
Showing 9 changed files with 1,052 additions and 529 deletions.
1 change: 1 addition & 0 deletions oracle-simple.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ library
Database.Oracle.Simple.Transaction
Database.Oracle.Simple.Queue
Database.Oracle.Simple.Object
Database.Oracle.Simple.LOB
hs-source-dirs:
src
c-sources:
Expand Down
4 changes: 3 additions & 1 deletion src/Database/Oracle/Simple.hs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ module Database.Oracle.Simple

-- * Miscellaneous
, module Export
, module LOB
) where

import Database.Oracle.Simple.Execute as Execute
Expand Down Expand Up @@ -108,6 +109,7 @@ import Database.Oracle.Simple.Queue as Queue
import Database.Oracle.Simple.ToField as ToField
import Database.Oracle.Simple.ToRow as ToRow
import Database.Oracle.Simple.Transaction as Transaction
import Database.Oracle.Simple.LOB as LOB

-- $use
-- This library provides a 'Query' type and a parameter substitution
Expand Down Expand Up @@ -182,4 +184,4 @@ import Database.Oracle.Simple.Transaction as Transaction
-- >
-- > print mPayload
-- > queueRelease queue
--
--
12 changes: 12 additions & 0 deletions src/Database/Oracle/Simple/FromField.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module Database.Oracle.Simple.FromField
getString,
getBool,
getTimestamp,
getLOB_,
)
where

Expand Down Expand Up @@ -94,6 +95,17 @@ instance FromField Time.UTCTime where
fromDPINativeType _ = DPI_NATIVE_TYPE_TIMESTAMP
fromField = dpiTimeStampToUTCTime <$> fromField

instance FromField DPILob where
fromDPINativeType _ = DPI_NATIVE_TYPE_LOB
fromField = FieldParser getLOB_

-- Question: For large object should the type be lazy bytestring
foreign import ccall "dpiData_getLOB"
dpiData_getLOB :: Ptr (DPIData ReadBuffer) -> IO DPILob

getLOB_ :: ReadDPIBuffer DPILob
getLOB_ = dpiData_getLOB

-- | Converts a 'DPITimestamp' to a 'Time.UTCTime'.
-- This function is useful for working with timestamps in Haskell's time library.
dpiTimeStampToUTCTime :: DPITimestamp -> Time.UTCTime
Expand Down
6 changes: 6 additions & 0 deletions src/Database/Oracle/Simple/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module Database.Oracle.Simple.Internal
DPIModeExec (..),
DPIConn (..),
DPIContext (..),
DPILob (..),
DPITimestamp (..),
DPIOracleType (..),
DPICommonCreateParams (..),
Expand Down Expand Up @@ -78,6 +79,7 @@ module Database.Oracle.Simple.Internal
dpiConn_close_finalizer,
dpiConn_release_finalizer,
dpiNativeTypeToUInt,
dpiOracleTypeToUInt,
)
where

Expand Down Expand Up @@ -133,6 +135,10 @@ newtype DPIShardingKeyColumn = DPIShardingKeyColumn (Ptr DPIShardingKeyColumn)
deriving (Show, Eq)
deriving newtype (Storable)

newtype DPILob = DPILob (Ptr DPILob)
deriving (Show, Eq)
deriving newtype (Storable)

-- | Represents additional parameters for creating a connection pool.
-- The 'AdditionalConnectionParams' data type includes settings such as session counts,
-- timeouts, and modes.
Expand Down
Loading

0 comments on commit f9fe17e

Please sign in to comment.