Skip to content

Commit fc18753

Browse files
committed
fix preserve_in_ast for record fields
`from` and `to` was mixed up, and not only it worked incorrectly, but it was also changing testcase table and passing the test. Closes #78
1 parent 4f47a4d commit fc18753

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

avro_schema/frontend.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ copy_schema = function(schema, context, ns, open_rec)
350350
for fieldno, xfield in ipairs(xfields) do
351351
ptr = fieldno
352352
local field = {}
353-
preserve_user_fields(field, xfield, context)
353+
preserve_user_fields(xfield, field, context)
354354
res.fields[fieldno] = field
355355
if type(xfield) ~= 'table' then
356356
copy_schema_error('Record field must be a list')
@@ -1195,9 +1195,9 @@ export_helper = function(node, already_built)
11951195
utils.copy_fields(node, res, {exclude={"fields"}})
11961196
for i, field in ipairs(node.fields) do
11971197
local xfield = {
1198-
name = field.name,
11991198
type = export_helper(field.type, already_built)
12001199
}
1200+
utils.copy_fields(field, xfield, {exclude={"type"}})
12011201
res.fields[i] = xfield
12021202
end
12031203
pack_nullable_to_type(res)

test/api_tests/export.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ res = {schema.create(
237237
preserve_in_fingerprint={"extra_field"}})}
238238
fingerprint = schema.fingerprint(res[2], "sha256", 32)
239239
test:is(string.lower(string.tohex(fingerprint)),
240-
"70bd295335daafff0a4512cadc39a4298cd81c460defec530c7372bdd1ec6f44",
241-
"Fingerprint extra fields 2")
240+
"ed1e8b275fe8c436839bdb2962f7595bbef6bc364dfdcd47d3d1334888350711",
241+
"Fingerprint extra fields 2")
242242

243243
res = {schema.create(
244244
{

0 commit comments

Comments
 (0)