You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by dk...@apache.org on 2020/05/26 12:07:30 UTC

[avro] branch master updated: AVRO-2844:Avro-js can't parse default value {}

This is an automated email from the ASF dual-hosted git repository.

dkulp pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/master by this push:
     new ad63705  AVRO-2844:Avro-js can't parse default value {}
ad63705 is described below

commit ad63705b30504ba385cde76c530a524843adf0fc
Author: zeshuai007 <51...@qq.com>
AuthorDate: Tue May 26 17:15:17 2020 +0800

    AVRO-2844:Avro-js can't parse default value {}
---
 lang/js/lib/schemas.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lang/js/lib/schemas.js b/lang/js/lib/schemas.js
index 2a3e5e5..2c9436e 100644
--- a/lang/js/lib/schemas.js
+++ b/lang/js/lib/schemas.js
@@ -1713,7 +1713,7 @@ RecordType.prototype._copy = function (val, opts) {
   var i, l, field, value;
   for (i = 0, l = this._fields.length; i < l; i++) {
     field = this._fields[i];
-    value = field._type._copy(val[field._name], opts);
+    value = field._type._copy(typeof val[field._name] == 'undefined' ? field.getDefault() : val[field._name], opts);
     if (hook) {
       value = hook(field, value, this);
     }