diff --git a/sbe/__init__.py b/sbe/__init__.py
index 73a1081..f38a17b 100644
--- a/sbe/__init__.py
+++ b/sbe/__init__.py
@@ -373,7 +373,7 @@ def hydrate(self, offset: int):
p1.offset = cursor
p1.hydrate()
self.pointers[k] = p1
- cursor += p1.numInGroup * p1.blockLength
+ cursor += p1.numInGroup * p1.blockLength + p.num_in_group_pointer.size + p.block_length_pointer.size
seen_group = True
else:
assert not seen_group
@@ -1040,7 +1040,7 @@ def _walk_fields_decode(schema: Schema, rv: dict, fields: List[Union[Group, Fiel
_walk_fields_decode_composite(schema, rv[f.name], f.type, vals, cursor)
else:
- if f.type.presence != Presence.CONSTANT:
+ if isinstance(f.type, PrimitiveType) or f.type.presence != Presence.CONSTANT:
_decode_value(schema, rv, f.name, f.type, vals, cursor)
def _parse_schema(f: TextIO) -> Schema:
diff --git a/tests/dat/example-schema.xml b/tests/dat/example-schema.xml
index c646a33..b6c5776 100644
--- a/tests/dat/example-schema.xml
+++ b/tests/dat/example-schema.xml
@@ -84,4 +84,13 @@
+
+
+
+
+
+
+
+
+
diff --git a/tests/test_sbe.py b/tests/test_sbe.py
index 587033b..5163301 100644
--- a/tests/test_sbe.py
+++ b/tests/test_sbe.py
@@ -38,3 +38,22 @@ def test_blockLength():
decoded = s.decode(encoded)
assert decoded.value['year'] == 1990
assert decoded.value['AGroup'][1]['numbers'] == 456
+
+def test_multiple_groups():
+ with open("tests/dat/example-schema.xml", "r", encoding="utf-8") as f:
+ s = sbe.Schema.parse(f)
+ msg = s.messages[4]
+
+ encoded = s.encode(
+ msg,
+ {
+ "year": 1990,
+ "AGroup": [{"numbers": 123}, {"numbers": 456}],
+ "BGroup": [{"numbers": 654}, {"numbers": 321}],
+ },
+ )
+
+ decoded = s.wrap(encoded)
+ assert decoded.body["year"] == 1990
+ assert decoded.body["AGroup"][1]["numbers"] == 456
+ assert decoded.body["BGroup"][1]["numbers"] == 321