|
11 | 11 | def check_protobuf_schema_compatibility(
|
12 | 12 | reader: ProtobufSchema, writer: ProtobufSchema, use_protopace: bool = False
|
13 | 13 | ) -> SchemaCompatibilityResult:
|
14 |
| - result = CompareResult() |
15 |
| - |
16 | 14 | if use_protopace:
|
17 | 15 | old_deps = []
|
18 |
| - for _, val in reader.dependencies.items(): |
19 |
| - old_deps.append(Proto(val.name, val.get_schema().schema_str)) |
20 |
| - old_proto = Proto(reader.record_name, reader.to_schema(), old_deps) |
| 16 | + # TODO: get dependencies recursive |
| 17 | + if reader.dependencies: |
| 18 | + for _, val in reader.dependencies.items(): |
| 19 | + old_deps.append(Proto(val.name, val.get_schema().schema_str)) |
| 20 | + old_proto = Proto("test.proto", reader.to_schema(), old_deps) |
21 | 21 |
|
22 | 22 | new_deps = []
|
23 |
| - for _, val in writer.dependencies.items(): |
24 |
| - new_deps.append(Proto(val.name, val.get_schema().schema_str)) |
25 |
| - new_proto = Proto(writer.record_name, writer.to_schema(), old_deps) |
| 23 | + if writer.dependencies: |
| 24 | + for _, val in writer.dependencies.items(): |
| 25 | + new_deps.append(Proto(val.name, val.get_schema().schema_str)) |
| 26 | + new_proto = Proto("test.proto", writer.to_schema(), new_deps) |
26 | 27 |
|
27 | 28 | try:
|
28 | 29 | check_compatibility(new_proto, old_proto)
|
29 |
| - except IncompatibleError: |
30 |
| - result.add_modification(Modification.PROTOPACE) |
| 30 | + except IncompatibleError as err: |
| 31 | + return SchemaCompatibilityResult( |
| 32 | + compatibility=SchemaCompatibilityType.incompatible, |
| 33 | + messages=set([str(err)]), |
| 34 | + ) |
31 | 35 |
|
32 |
| - return result |
| 36 | + return SchemaCompatibilityResult(SchemaCompatibilityType.compatible) |
33 | 37 |
|
| 38 | + result = CompareResult() |
34 | 39 | writer.compare(reader, result)
|
35 | 40 | if result.is_compatible():
|
36 | 41 | return SchemaCompatibilityResult(SchemaCompatibilityType.compatible)
|
|
0 commit comments