dataframe-persistent 0.4.0.1 → 0.5.0.0
raw patch · 3 files changed
+10/−12 lines, 3 filesdep ~dataframe-coredep ~dataframe-operationsPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: dataframe-core, dataframe-operations
API changes (from Hackage documentation)
- DataFrame.IO.Persistent.Read: freezeOrThrow :: forall (cols :: [Type]) m. (KnownSchema cols, MonadIO m) => DataFrame -> m (TypedDataFrame cols)
+ DataFrame.IO.Persistent.Read: freezeOrThrow :: forall (cols :: [(Symbol, Type)]) m. (KnownSchema cols, MonadIO m) => DataFrame -> m (TypedDataFrame cols)
- DataFrame.IO.Persistent.Read: readSqlTyped :: forall (cols :: [Type]). KnownSchema cols => FilePath -> Text -> IO (TypedDataFrame cols)
+ DataFrame.IO.Persistent.Read: readSqlTyped :: forall (cols :: [(Symbol, Type)]). KnownSchema cols => FilePath -> Text -> IO (TypedDataFrame cols)
- DataFrame.IO.Persistent.Read: readTableTyped :: forall (cols :: [Type]). KnownSchema cols => FilePath -> Text -> IO (TypedDataFrame cols)
+ DataFrame.IO.Persistent.Read: readTableTyped :: forall (cols :: [(Symbol, Type)]). KnownSchema cols => FilePath -> Text -> IO (TypedDataFrame cols)
- DataFrame.IO.Persistent.Read: readTableTypedConn :: forall (cols :: [Type]) (m :: Type -> Type). (KnownSchema cols, MonadResource m) => Text -> ReaderT SqlBackend m (TypedDataFrame cols)
+ DataFrame.IO.Persistent.Read: readTableTypedConn :: forall (cols :: [(Symbol, Type)]) (m :: Type -> Type). (KnownSchema cols, MonadResource m) => Text -> ReaderT SqlBackend m (TypedDataFrame cols)
- DataFrame.IO.Persistent.Read.Columns: freezeOrThrow :: forall (cols :: [Type]) m. (KnownSchema cols, MonadIO m) => DataFrame -> m (TypedDataFrame cols)
+ DataFrame.IO.Persistent.Read.Columns: freezeOrThrow :: forall (cols :: [(Symbol, Type)]) m. (KnownSchema cols, MonadIO m) => DataFrame -> m (TypedDataFrame cols)
Files
- README.md +1/−1
- dataframe-persistent.cabal +4/−5
- src/DataFrame/IO/Persistent/Schema.hs +5/−6
README.md view
@@ -126,7 +126,7 @@ > <!-- scripths:mime text/plain --> The splice brings one thing into scope, the type-`type ArtistsSchema = '[Column "ArtistId" Int, Column "Name" (Maybe Text)]`:+`type ArtistsSchema = '[ '("ArtistId", Int), '("Name", Maybe Text)]`: ```haskell $(declareTable "./data/chinook.db" "artists")
dataframe-persistent.cabal view
@@ -1,7 +1,6 @@ cabal-version: 3.0 name: dataframe-persistent-version: 0.4.0.1-+version: 0.5.0.0 synopsis: Persistent database integration for the dataframe library description: This package provides integration between the dataframe library and the Persistent database library, allowing you to load database entities into DataFrames and save DataFrames back to the database.@@ -44,8 +43,8 @@ bytestring >= 0.10 && < 0.14, conduit >= 1.3 && < 1.5, containers >= 0.6.7 && < 0.10,- dataframe-core ^>= 2.1,- dataframe-operations ^>= 2.1,+ dataframe-core ^>= 2.2,+ dataframe-operations ^>= 2.2, persistent >= 2.14 && < 3, persistent-sqlite >= 2.13 && < 3, resourcet >= 1.2 && < 2,@@ -65,7 +64,7 @@ SchemaTHTests build-depends: base >= 4 && < 5, dataframe >= 1 && < 4,- dataframe-operations ^>= 2.1,+ dataframe-operations ^>= 2.2, dataframe-persistent, HUnit >= 1.6 && < 1.8, monad-logger >= 0.3 && < 0.5,
src/DataFrame/IO/Persistent/Schema.hs view
@@ -17,7 +17,7 @@ @ -- Typed schema, checked at compile time: \$('declareTable' "chinook.db" "artists")--- generates: type ArtistsSchema = '[Column "ArtistId" Int, Column "Name" (Maybe Text)]+-- generates: type ArtistsSchema = '[ '("ArtistId", Int), '("Name", Maybe Text)] -- read any database/table into it: -- readTableTyped \@ArtistsSchema "chinook.db" "artists" :: IO (TypedDataFrame ArtistsSchema) @@ -54,10 +54,9 @@ import DataFrame.IO.Persistent.Schema.Common import DataFrame.IO.Persistent.Schema.Introspect-import DataFrame.Typed.Types (Column) {- | Read @table@ from the SQLite database at @path@ and emit a typed schema-synonym, @type \<Table\>Schema = '[Column ...]@. Read into it with+synonym, @type \<Table\>Schema = '[ '(name, ty), ...]@. Read into it with 'DataFrame.IO.Persistent.Read.readTableTyped'. -} declareTable :: FilePath -> String -> Q [Dec]@@ -77,7 +76,7 @@ declareTableFromSchema cols name = schemaDecl defaultDeclareOptions (T.pack name) cols --- | Emit @type \<Table\>Schema = '[Column ...]@ for the selected columns.+-- | Emit @type \<Table\>Schema = '[ '(name, ty), ...]@ for the selected columns. schemaDecl :: DeclareOptions -> Text -> [ColumnInfo] -> Q [Dec] schemaDecl opts table cols0 = do let cols = selectColumns opts cols0@@ -94,7 +93,7 @@ buildSchemaType [(ciName c, thType (resolvedType opts c), isNullable opts c) | c <- cols] --- | Fold @(name, type, nullable)@ triples into a promoted @'[Column name ty]@.+-- | Fold @(name, type, nullable)@ triples into a promoted @'[ '(name, ty)]@. buildSchemaType :: [(Text, Type, Bool)] -> Type buildSchemaType = foldr cons PromotedNilT where@@ -102,7 +101,7 @@ columnEntry :: (Text, Type, Bool) -> Type columnEntry (name, ty, nullable) =- ConT ''Column+ PromotedTupleT 2 `AppT` LitT (StrTyLit (T.unpack name)) `AppT` wrapMaybe nullable ty