avro 0.3.4.2 → 0.3.4.3
raw patch · 4 files changed
+147/−1 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.Avro.Decode.Get: instance Data.Avro.Decode.Get.GetAvro a => Data.Avro.Decode.Get.GetAvro (GHC.Base.Maybe a)
- Data.Avro.Encode: instance Data.Avro.Encode.EncodeAvro a => Data.Avro.Encode.EncodeAvro (GHC.Base.Maybe a)
- Data.Avro.FromAvro: instance Data.Avro.FromAvro.FromAvro a => Data.Avro.FromAvro.FromAvro (GHC.Base.Maybe a)
- Data.Avro.HasAvroSchema: instance Data.Avro.HasAvroSchema.HasAvroSchema a => Data.Avro.HasAvroSchema.HasAvroSchema (GHC.Base.Maybe a)
- Data.Avro.ToAvro: instance Data.Avro.ToAvro.ToAvro a => Data.Avro.ToAvro.ToAvro (GHC.Base.Maybe a)
+ Data.Avro.Decode.Get: instance Data.Avro.Decode.Get.GetAvro a => Data.Avro.Decode.Get.GetAvro (GHC.Maybe.Maybe a)
+ Data.Avro.Encode: instance Data.Avro.Encode.EncodeAvro a => Data.Avro.Encode.EncodeAvro (GHC.Maybe.Maybe a)
+ Data.Avro.FromAvro: instance Data.Avro.FromAvro.FromAvro a => Data.Avro.FromAvro.FromAvro (GHC.Maybe.Maybe a)
+ Data.Avro.HasAvroSchema: instance Data.Avro.HasAvroSchema.HasAvroSchema a => Data.Avro.HasAvroSchema.HasAvroSchema (GHC.Maybe.Maybe a)
+ Data.Avro.ToAvro: instance Data.Avro.ToAvro.ToAvro a => Data.Avro.ToAvro.ToAvro (GHC.Maybe.Maybe a)
- Data.Avro: schemaOf :: (HasAvroSchema a) => a -> Type
+ Data.Avro: schemaOf :: HasAvroSchema a => a -> Type
- Data.Avro.Decode.Get: ContainerHeader :: !ByteString -> ByteString -> Get ByteString -> !Schema -> ContainerHeader
+ Data.Avro.Decode.Get: ContainerHeader :: !ByteString -> (ByteString -> Get ByteString) -> !Schema -> ContainerHeader
- Data.Avro.Decode.Lazy.LazyValue: Array :: (Vector (LazyValue f)) -> LazyValue f
+ Data.Avro.Decode.Lazy.LazyValue: Array :: Vector (LazyValue f) -> LazyValue f
- Data.Avro.Decode.Lazy.LazyValue: Map :: (HashMap Text (LazyValue f)) -> LazyValue f
+ Data.Avro.Decode.Lazy.LazyValue: Map :: HashMap Text (LazyValue f) -> LazyValue f
- Data.Avro.Decode.Lazy.LazyValue: Record :: f -> (HashMap Text (LazyValue f)) -> LazyValue f
+ Data.Avro.Decode.Lazy.LazyValue: Record :: f -> HashMap Text (LazyValue f) -> LazyValue f
- Data.Avro.Decode.Lazy.LazyValue: Union :: (NonEmpty f) -> f -> (LazyValue f) -> LazyValue f
+ Data.Avro.Decode.Lazy.LazyValue: Union :: NonEmpty f -> f -> LazyValue f -> LazyValue f
- Data.Avro.Deriving: DeriveOptions :: TypeName -> Field -> Text -> TypeName -> Field -> (FieldStrictness, FieldUnpackedness) -> DeriveOptions
+ Data.Avro.Deriving: DeriveOptions :: (TypeName -> Field -> Text) -> (TypeName -> Field -> (FieldStrictness, FieldUnpackedness)) -> DeriveOptions
- Data.Avro.HasAvroSchema: schemaOf :: (HasAvroSchema a) => a -> Type
+ Data.Avro.HasAvroSchema: schemaOf :: HasAvroSchema a => a -> Type
- Data.Avro.JSON: fromJSON :: forall a. (FromAvro a) => Value -> Result a
+ Data.Avro.JSON: fromJSON :: forall a. FromAvro a => Value -> Result a
- Data.Avro.JSON: parseJSON :: forall a. (FromAvro a) => ByteString -> Result a
+ Data.Avro.JSON: parseJSON :: forall a. FromAvro a => ByteString -> Result a
- Data.Avro.JSON: toJSON :: forall a. (ToAvro a) => a -> Value
+ Data.Avro.JSON: toJSON :: forall a. ToAvro a => a -> Value
- Data.Avro.Schema: Enum :: TypeName -> Maybe Text -> [TypeName] -> Maybe Text -> [Text] -> Int64 -> Maybe Text -> Type
+ Data.Avro.Schema: Enum :: TypeName -> Maybe Text -> [TypeName] -> Maybe Text -> [Text] -> (Int64 -> Maybe Text) -> Type
- Data.Avro.Schema: Union :: NonEmpty Type -> Int64 -> Maybe Type -> Type
+ Data.Avro.Schema: Union :: NonEmpty Type -> (Int64 -> Maybe Type) -> Type
- Data.Avro.Types.Value: Array :: (Vector (Value f)) -> Value f
+ Data.Avro.Types.Value: Array :: Vector (Value f) -> Value f
- Data.Avro.Types.Value: Map :: (HashMap Text (Value f)) -> Value f
+ Data.Avro.Types.Value: Map :: HashMap Text (Value f) -> Value f
- Data.Avro.Types.Value: Record :: f -> (HashMap Text (Value f)) -> Value f
+ Data.Avro.Types.Value: Record :: f -> HashMap Text (Value f) -> Value f
- Data.Avro.Types.Value: Union :: (NonEmpty f) -> f -> (Value f) -> Value f
+ Data.Avro.Types.Value: Union :: NonEmpty f -> f -> Value f -> Value f
Files
- avro.cabal +3/−1
- src/Data/Avro/Schema.hs +1/−0
- test/Avro/SchemaSpec.hs +38/−0
- test/data/internal-bindings.avsc +105/−0
avro.cabal view
@@ -5,7 +5,7 @@ -- hash: 307ace222c16e9660fc8fd8f1d3b126a4254daea39bb616b93782a86b81d73b0 name: avro-version: 0.3.4.2+version: 0.3.4.3 synopsis: Avro serialization support for Haskell description: Avro serialization and deserialization support for Haskell category: Data@@ -23,6 +23,7 @@ test/data/deconflict/writer.avsc test/data/enums-object.json test/data/enums.avsc+ test/data/internal-bindings.avsc test/data/karma.avsc test/data/logical.avsc test/data/maybe.avsc@@ -136,6 +137,7 @@ Avro.THSimpleSpec Avro.THUnionSpec Avro.ToAvroSpec+ Avro.SchemaSpec DecodeContainer Example1 Paths_avro
src/Data/Avro/Schema.hs view
@@ -544,6 +544,7 @@ Union {..} -> concatMap go options Fixed {..} -> mk name aliases namespace Array {..} -> go item+ Map {..} -> go values _ -> [] -- | Checks that two schemas match. This is like equality of schemas,
+ test/Avro/SchemaSpec.hs view
@@ -0,0 +1,38 @@+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TemplateHaskell #-}+module Avro.SchemaSpec+where++import Data.Avro+import Data.Avro.Deriving (makeSchema)+import Data.Avro.Schema (buildTypeEnvironment, matches)++import Test.Hspec++{-# ANN module ("HLint: ignore Redundant do" :: String) #-}++spec :: Spec+spec = describe "Avro.SchemaSpec" $ do+ describe "buildTypeEnvironment" $+ it "should contain definitions for all internal types" $ do+ let schema = $(makeSchema "test/data/internal-bindings.avsc")+ environment = buildTypeEnvironment err schema+ err name = fail $ "Missing " ++ show name ++ " in environment."+ expected =+ [ "InternalBindings"+ , "InField"+ , "NestedInField"+ , "AliasNestedInField"+ , "NestedEnum"+ , "NestedFixed"+ , "InArray"+ , "NestedInArray"+ , "InMap"+ , "NestedInMap"+ , "InUnionA"+ , "InUnionB"+ ]+ definitions <- traverse environment expected+ length definitions `shouldBe` length expected
+ test/data/internal-bindings.avsc view
@@ -0,0 +1,105 @@+{+ "name" : "InternalBindings",+ "type" : "record",+ "doc" : "A test record that includes subdefinitions nested in different ways.",+ "fields" : [+ {+ "name" : "inField",+ "doc" : "A record definition nested in a field of a record.",+ "type" : {+ "name" : "InField",+ "type" : "record",+ "fields" : [+ {+ "name" : "nestedInField",+ "doc" : "A record definition nested in two other records.",+ "type" : {+ "name" : "NestedInField",+ "type" : "record",+ "aliases" : ["AliasNestedInField"],+ "fields" : []+ }+ },+ {+ "name" : "nestedEnum",+ "doc" : "An enum definition nested in a nested record.",+ "type" : {+ "type" : "enum",+ "name" : "NestedEnum",+ "symbols" : ["Foo", "Bar"]+ }+ },+ {+ "name" : "nestedFixed",+ "doc" : "A fixed definition nested in a nested record.",+ "type" : {+ "type" : "fixed",+ "size" : 42,+ "name" : "NestedFixed"+ }+ }+ ]+ }+ },+ {+ "name" : "inArray",+ "doc" : "A record definition nested in an array type.",+ "type" : {+ "type" : "array",+ "items" : {+ "name" : "InArray",+ "type" : "record",+ "fields" : [+ {+ "name" : "nestedInArray",+ "doc" : "A record definition nested inside a record defined in an array.",+ "type" : {+ "name" : "NestedInArray",+ "type" : "record",+ "fields" : []+ }+ }+ ]+ }+ }+ },+ {+ "name" : "inMap",+ "doc" : "A record definition nested in a map type.",+ "type" : {+ "type" : "map",+ "values" : {+ "name" : "InMap",+ "type" : "record",+ "fields" : [+ {+ "name" : "nestedInMap",+ "doc" : "A record definition nested inside a record defined in a map.",+ "type" : {+ "name" : "NestedInMap",+ "type" : "record",+ "fields" : []+ }+ }+ ]+ }+ }+ },+ {+ "name" : "inUnion",+ "doc" : "Record definitions nested in a union.",+ "type" : [+ {+ "name" : "InUnionA",+ "type" : "record",+ "fields" : []+ },+ {+ "name" : "InUnionB",+ "type" : "record",+ "fields" : []+ }+ ]+ }+ ]+}