packages feed

influxdb 1.9.1 → 1.9.1.1

raw patch · 10 files changed

+70/−45 lines, 10 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,6 +1,10 @@ # Revision history for influxdb -## v1.9.1 - 2020-02-21+## v1.9.1.1 - 2021-03-12++* Support GHC 9.0.1 ([#85](https://github.com/maoe/influxdb-haskell/pull/85))++## v1.9.1 - 2021-02-21  * Show error on the "impossible" path in writeByteString ([#82](https://github.com/maoe/influxdb-haskell/pull/82)) * Relax upper version bounds for lens, time, doctest, and bytestring
influxdb.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.24 name: influxdb-version: 1.9.1+version: 1.9.1.1 synopsis: InfluxDB client library for Haskell description:   @influxdb@ is an InfluxDB client library for Haskell.@@ -19,6 +19,7 @@   GHC == 8.6.5   GHC == 8.8.4   GHC == 8.10.4+  GHC == 9.0.1  extra-source-files:   README.md@@ -73,7 +74,7 @@     ViewPatterns   ghc-options: -Wall   build-depends:-      base >= 4.11 && < 4.15+      base >= 4.11 && < 4.16     , aeson >= 0.7 && < 1.6     , attoparsec < 0.14     , bytestring >= 0.10 && < 0.12
src/Database/InfluxDB/Format.hs view
@@ -2,7 +2,9 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} module Database.InfluxDB.Format-  ( -- * The 'Format' type and associated functions+  ( -- $setup++  -- * The 'Format' type and associated functions     Format   , makeFormat   , (%)@@ -50,9 +52,14 @@ import Database.InfluxDB.Internal.Text import Database.InfluxDB.Types hiding (database) --- $setup--- >>> :set -XOverloadedStrings+{- $setup+This module is desined to be imported qualified: +>>> :set -XOverloadedStrings+>>> import qualified Data.ByteString as B+>>> import qualified Database.InfluxDB.Format as F+-}+ -- | Serialize a 'Query' to a 'B.ByteString'. fromQuery :: Query -> B.ByteString fromQuery (Query q) =@@ -61,15 +68,15 @@ -- | A typed format string. @Format a r@ means that @a@ is the type of formatted -- string, and @r@ is the type of the formatter. ----- >>> :t formatQuery--- formatQuery :: Format Query r -> r--- >>> :t key--- key :: Format r (Key -> r)--- >>> :t "SELECT * FROM "%key--- "SELECT * FROM "%key :: Format a (Key -> a)--- >>> :t formatQuery ("SELECT * FROM "%key)--- formatQuery ("SELECT * FROM "%key) :: Key -> Query--- >>> formatQuery ("SELECT * FROM "%key) "series"+-- >>> :t F.formatQuery+-- F.formatQuery :: F.Format Query r -> r+-- >>> :t F.key+-- F.key :: F.Format r (Key -> r)+-- >>> :t "SELECT * FROM "%F.key+-- "SELECT * FROM "%F.key :: F.Format a (Key -> a)+-- >>> :t F.formatQuery ("SELECT * FROM "%F.key)+-- F.formatQuery ("SELECT * FROM "%F.key) :: Key -> Query+-- >>> F.formatQuery ("SELECT * FROM "%F.key) "series" -- "SELECT * FROM \"series\"" newtype Format a r = Format { runFormat :: (TL.Builder -> a) -> r } @@ -77,7 +84,7 @@ -- -- >>> import Control.Category ((.)) -- >>> import Prelude hiding ((.))--- >>> formatQuery ("SELECT * FROM " . key) "series"+-- >>> F.formatQuery ("SELECT * FROM " . F.key) "series" -- "SELECT * FROM \"series\"" instance Category Format where   id = Format (\k -> k "")@@ -106,36 +113,36 @@  -- | Format a 'Query'. ----- >>> formatQuery "SELECT * FROM series"+-- >>> F.formatQuery "SELECT * FROM series" -- "SELECT * FROM series"--- >>> formatQuery ("SELECT * FROM "%key) "series"+-- >>> F.formatQuery ("SELECT * FROM "%F.key) "series" -- "SELECT * FROM \"series\"" formatQuery :: Format Query r -> r formatQuery = runFormatWith Query  -- | Format a 'Database'. ----- >>> formatDatabase "test-db"+-- >>> F.formatDatabase "test-db" -- "test-db"--- >>> formatDatabase ("test-db-"%decimal) 0+-- >>> F.formatDatabase ("test-db-"%F.decimal) 0 -- "test-db-0" formatDatabase :: Format Database r -> r formatDatabase = runFormatWith Database  -- | Format a 'Measurement'. ----- >>> formatMeasurement "test-series"+-- >>> F.formatMeasurement "test-series" -- "test-series"--- >>> formatMeasurement ("test-series-"%decimal) 0+-- >>> F.formatMeasurement ("test-series-"%F.decimal) 0 -- "test-series-0" formatMeasurement :: Format Measurement r -> r formatMeasurement = runFormatWith Measurement  -- | Format a 'Key'. ----- >>> formatKey "test-key"+-- >>> F.formatKey "test-key" -- "test-key"--- >>> formatKey ("test-key-"%decimal) 0+-- >>> F.formatKey ("test-key-"%F.decimal) 0 -- "test-key-0" formatKey :: Format Key r -> r formatKey fmt = runFormat fmt (Key . TL.toStrict . TL.toLazyText)@@ -158,7 +165,7 @@  -- | Format a database name. ----- >>> formatQuery ("CREATE DATABASE "%database) "test-db"+-- >>> F.formatQuery ("CREATE DATABASE "%F.database) "test-db" -- "CREATE DATABASE \"test-db\"" database :: Format r (Database -> r) database = makeFormat $ \(Database name) -> identifierBuilder name@@ -167,16 +174,16 @@ -- -- Identifiers in InfluxDB protocol are surrounded with double quotes. ----- >>> formatQuery ("SELECT "%key%" FROM series") "field"+-- >>> F.formatQuery ("SELECT "%F.key%" FROM series") "field" -- "SELECT \"field\" FROM series"--- >>> formatQuery ("SELECT "%key%" FROM series") "foo\"bar"+-- >>> F.formatQuery ("SELECT "%F.key%" FROM series") "foo\"bar" -- "SELECT \"foo\\\"bar\" FROM series" key :: Format r (Key -> r) key = makeFormat $ \(Key name) -> identifierBuilder name  -- | Format multiple keys. ----- >>> formatQuery ("SELECT "%keys%" FROM series") ["field1", "field2"]+-- >>> F.formatQuery ("SELECT "%F.keys%" FROM series") ["field1", "field2"] -- "SELECT \"field1\",\"field2\" FROM series" keys :: Format r ([Key] -> r) keys = makeFormat $@@ -184,14 +191,14 @@  -- | Format a measurement. ----- >>> formatQuery ("SELECT * FROM "%measurement) "test-series"+-- >>> F.formatQuery ("SELECT * FROM "%F.measurement) "test-series" -- "SELECT * FROM \"test-series\"" measurement :: Format r (Measurement -> r) measurement = makeFormat $ \(Measurement name) -> identifierBuilder name  -- | Format a measurement. ----- >>> formatQuery ("SELECT * FROM "%measurements) ["series1", "series2"]+-- >>> F.formatQuery ("SELECT * FROM "%F.measurements) ["series1", "series2"] -- "SELECT * FROM \"series1\",\"series2\"" measurements :: Format r ([Measurement] -> r) measurements = makeFormat $@@ -200,7 +207,7 @@  -- | Format an InfluxDB value. Good for field and tag values. ----- >>> formatQuery ("SELECT * FROM series WHERE "%key%" = "%field) "location" "tokyo"+-- >>> F.formatQuery ("SELECT * FROM series WHERE "%F.key%" = "%F.field) "location" "tokyo" -- "SELECT * FROM series WHERE \"location\" = 'tokyo'" field :: Format r (QueryField -> r) field = makeFormat $ \case@@ -212,14 +219,14 @@  -- | Format a decimal number. ----- >>> formatQuery ("SELECT * FROM series WHERE time < now() - "%decimal%"h") 1+-- >>> F.formatQuery ("SELECT * FROM series WHERE time < now() - "%F.decimal%"h") 1 -- "SELECT * FROM series WHERE time < now() - 1h" decimal :: Integral a => Format r (a -> r) decimal = makeFormat TL.decimal  -- | Format a floating-point number. ----- >>> formatQuery ("SELECT * FROM series WHERE value > "%realFloat) 0.1+-- >>> F.formatQuery ("SELECT * FROM series WHERE value > "%F.realFloat) 0.1 -- "SELECT * FROM series WHERE value > 0.1" realFloat :: RealFloat a => Format r (a -> r) realFloat = makeFormat TL.realFloat@@ -229,8 +236,8 @@ -- Note that this doesn't escape the string. Use 'formatKey' to format field -- values in a query. ----- >>> :t formatKey text--- formatKey text :: T.Text -> Key+-- >>> :t F.formatKey F.text+-- F.formatKey F.text :: T.Text -> Key text :: Format r (T.Text -> r) text = makeFormat TL.fromText @@ -239,8 +246,8 @@ -- Note that this doesn't escape the string. Use 'formatKey' to format field -- values in a query. ----- >>> :t formatKey string--- formatKey string :: String -> Key+-- >>> :t F.formatKey F.string+-- F.formatKey F.string :: String -> Key string :: Format r (String -> r) string = makeFormat TL.fromString @@ -249,8 +256,8 @@ -- Note that this doesn't escape the string. Use 'formatKey' to format field -- values in a query. ----- >>> :t formatKey byteString8--- formatKey byteString8 :: B.ByteString -> Key+-- >>> :t F.formatKey F.byteString8+-- F.formatKey F.byteString8 :: B.ByteString -> Key byteString8 :: Format r (B.ByteString -> r) byteString8 = makeFormat $ TL.fromText . T.decodeUtf8 @@ -258,7 +265,7 @@ -- -- >>> import Data.Time -- >>> let Just t = parseTimeM False defaultTimeLocale "%s" "0" :: Maybe UTCTime--- >>> formatQuery ("SELECT * FROM series WHERE time >= "%time) t+-- >>> F.formatQuery ("SELECT * FROM series WHERE time >= "%F.time) t -- "SELECT * FROM series WHERE time >= '1970-01-01 00:00:00'" time :: FormatTime time => Format r (time -> r) time = makeFormat $ \t ->
src/Database/InfluxDB/Line.hs view
@@ -45,10 +45,12 @@ The Line protocol implementation.  >>> :set -XOverloadedStrings->>> import Database.InfluxDB >>> import Data.Time->>> import qualified Data.ByteString.Lazy.Char8 as BL8+>>> import Database.InfluxDB.Line >>> import System.IO (stdout)+>>> import qualified Data.ByteString as B+>>> import qualified Data.ByteString.Builder as B+>>> import qualified Data.ByteString.Lazy.Char8 as BL8 >>> :{ let l1 = Line "cpu_usage"       (Map.singleton "cpu" "cpu-total")
src/Database/InfluxDB/Manage.hs view
@@ -60,6 +60,7 @@ -- >>> :set -XOverloadedStrings -- >>> import Database.InfluxDB.Query -- >>> import Database.InfluxDB.Format ((%))+-- >>> import Database.InfluxDB.Manage  -- | Send a database management query to InfluxDB. --
src/Database/InfluxDB/Ping.hs view
@@ -34,6 +34,9 @@  import Database.InfluxDB.Types as Types +-- $setup+-- >>> import Database.InfluxDB.Ping+ -- Ping requests do not require authentication -- | The full set of parameters for the ping API --
src/Database/InfluxDB/Query.hs view
@@ -83,6 +83,7 @@ -- >>> :set -XTypeApplications -- >>> import Data.Time (UTCTime) -- >>> import qualified Data.Vector as V+-- >>> import qualified Data.Text as T  -- | Types that can be converted from an JSON object returned by InfluxDB. --@@ -202,7 +203,7 @@ -- -- >>> let p = queryParams "_internal" -- >>> dbs <- query @(Tagged "name" T.Text) p "SHOW DATABASES"--- >>> find ((== "_internal") . untag) dbs+-- >>> V.find ((== "_internal") . untag) dbs -- Just (Tagged "_internal") instance (KnownSymbol k, FromJSON v) => QueryResults (Tagged k v) where   parseMeasurement _ _name _ columns fields =
src/Database/InfluxDB/Types.hs view
@@ -30,6 +30,7 @@  -- $setup -- >>> :set -XOverloadedStrings+-- >>> import System.Clock (TimeSpec(..)) -- >>> import Database.InfluxDB -- >>> import qualified Database.InfluxDB.Format as F 
src/Database/InfluxDB/Write.hs view
@@ -50,7 +50,8 @@ -- >>> import qualified Data.Map as Map -- >>> import Data.Time -- >>> import Database.InfluxDB--- >>> manage (queryParams "test-db") "CREATE DATABASE \"test-db\""+-- >>> import qualified Network.HTTP.Client as HC+-- >>> Database.InfluxDB.manage (queryParams "test-db") "CREATE DATABASE \"test-db\""  {- $intro The code snippets in this module assume the following imports.
tests/doctests.hs view
@@ -4,4 +4,8 @@ import Test.DocTest (doctest)  main :: IO ()-main = doctest $ flags ++ pkgs ++ module_sources+main = doctest+  $ "-fobject-code"+  --- ^ Use object code to work around https://gitlab.haskell.org/ghc/ghc/-/issues/19460+  -- in GHC 9.0.1.+  : flags ++ pkgs ++ module_sources