Skip to content

Commit

Permalink
Merge commit 'refs/pull/16/head' of https://github.com/hackolade/Avro
Browse files Browse the repository at this point in the history
Resolve recusrsive references
  • Loading branch information
pdesmarets committed Jan 14, 2021
2 parents d0fd404 + 6929ad8 commit 52ae041
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Avro",
"version": "0.1.51",
"versionDate": "2021-01-08",
"version": "0.1.52",
"versionDate": "2021-01-14",
"author": "hackolade",
"engines": {
"hackolade": "3.3.2",
Expand Down
11 changes: 11 additions & 0 deletions reverse_engineering/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,16 @@ const handleMultipleTypes = (data, schema, parentSchema, definitions) => {
}
};

const resolveRecursiveReferences = (parentName, child) => {
if (!child || parentName !== child.type) {
return child;
}

child.type = 'string';

return child;
};

const addDefinitions = (types, definitions) => {
return types.map(type => {
if (Object(type) !== type) {
Expand All @@ -263,6 +273,7 @@ const addDefinitions = (types, definitions) => {
let schema = {};
const { name, namespace } = getNameAndNamespace(type.name);
type.name = name;
type = resolveRecursiveReferences(name, type);

handleRecursiveSchema(type, schema, {}, definitions);
if (namespace) {
Expand Down
2 changes: 1 addition & 1 deletion reverse_engineering/helpers/adaptJsonSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const handleNumber = field => {

return Object.assign({}, field, {
type: 'bytes',
logicalType: 'decimal'
subtype: 'decimal'
});
};

Expand Down

0 comments on commit 52ae041

Please sign in to comment.