avro 0.3.0.3 → 0.3.0.4
raw patch · 4 files changed
+38/−4 lines, 4 files
Files
- avro.cabal +3/−2
- src/Data/Avro/Deriving/NormSchema.hs +2/−1
- test/Avro/NormSchemaSpec.hs +7/−1
- test/data/karma.avsc +26/−0
avro.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 759fe76ae3c64abc46a255c2a85695fd7860adbf99c1d5d0190e76189fc0f949+-- hash: 2b77c4a4ff781ee32d8fcf7764aee0064f08ceefccd8579cfa2fc8a2d6c1ecf3 name: avro-version: 0.3.0.3+version: 0.3.0.4 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/karma.avsc test/data/maybe.avsc test/data/reused.avsc test/data/small.avsc
src/Data/Avro/Deriving/NormSchema.hs view
@@ -57,9 +57,10 @@ Array s -> Array <$> normSchema s Map s -> Map <$> normSchema s+ Union l f -> flip Union f <$> traverse normSchema l r@Record{name = tn} -> do let sn = shortName tn- modify' (M.insert sn r)+ modify' (M.insert sn (NamedType tn)) flds <- mapM (\fld -> setType fld <$> normSchema (fldType fld)) (fields r) pure $ r { fields = flds } s -> pure s
test/Avro/NormSchemaSpec.hs view
@@ -6,7 +6,8 @@ import Data.Avro import Data.Avro.Deriving-import Data.Avro.Schema (Type (..), fields, fldType)+import Data.Avro.Schema (Type (..), fields, fldType, mkUnion)+import Data.List.NonEmpty (NonEmpty (..)) import qualified Data.Set as S import Test.Hspec@@ -15,7 +16,12 @@ deriveAvro "test/data/reused.avsc" +deriveAvro "test/data/karma.avsc"+ spec :: Spec spec = describe "Avro.NormSchemaSpec" $ do it "should have one full inner schema for each type" $ (fldType <$> fields schema'ContainerChild) `shouldBe` [schema'ReusedChild, NamedType "ReusedChild"]++ it "should normalise schemas from unions" $+ fldType <$> fields schema'Curse `shouldBe` [mkUnion (Null :| [schema'Geo])]
+ test/data/karma.avsc view
@@ -0,0 +1,26 @@+[{+ "type": "record",+ "name": "Blessing",+ "namespace": "avro.test.data",+ "fields": [+ { "name": "geo",+ "type": ["null", {+ "type": "record",+ "name": "Geo",+ "fields": [+ { "name": "source", "type": "string" },+ { "name": "dest", "type": "string" }+ ]+ }]+ }+ ]+ },+ {+ "type": "record",+ "name": "Curse",+ "namespace": "avro.test.data",+ "fields": [+ { "name": "geo", "type": ["null", "Geo"] }+ ]+ }+]