From 6135751ee109a3952bdc711fa61014ec7e02c906 Mon Sep 17 00:00:00 2001 From: Mikhail Tseluiko Date: Fri, 16 Dec 2022 14:42:49 +0200 Subject: [PATCH] Confluent: fixed separator for RecordName subject. Fixed detection of subject name strategy for RecordNameStrategy --- .../helpers/formatAvroSchemaByType.js | 12 ++++++------ reverse_engineering/api.js | 4 ++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/forward_engineering/helpers/formatAvroSchemaByType.js b/forward_engineering/helpers/formatAvroSchemaByType.js index 69b651c..b4b897c 100644 --- a/forward_engineering/helpers/formatAvroSchemaByType.js +++ b/forward_engineering/helpers/formatAvroSchemaByType.js @@ -76,19 +76,19 @@ const getConfluentPostQuery = ({ return confluentSubjectName; } - const typePostfix = schemaType ? `-${schemaType}` : ''; - const containerPrefix = namespace ? `${namespace}.`:''; + const typePostfix = schemaType || ''; + const containerPrefix = namespace || ''; const topicPrefix = schemaTopic || ''; switch(schemaNameStrategy){ case RECORD_NAME_STRATEGY: - return `${containerPrefix}${name}${typePostfix}` + return [containerPrefix, name, typePostfix].filter(Boolean).join('-'); case TOPIC_NAME_STRATEGY: - return `${topicPrefix || name}${typePostfix}` + return [topicPrefix || name, typePostfix].filter(Boolean).join('-'); case TOPIC_RECORD_NAME_STRATEGY: - return `${topicPrefix}-${containerPrefix}${name}${typePostfix}` + return [topicPrefix, containerPrefix, name, typePostfix].filter(Boolean).join('-'); default: - return `${name}${typePostfix}`; + return [name, typePostfix].filter(Boolean).join('-'); } } diff --git a/reverse_engineering/api.js b/reverse_engineering/api.js index 20fc670..69aba62 100644 --- a/reverse_engineering/api.js +++ b/reverse_engineering/api.js @@ -99,6 +99,10 @@ const inferSchemaNameStrategy = ({ name, namespace, confluentSubjectName, schema } if (startsWithTopic && _.isEmpty(splittedSubjectName)) { + if (name === schemaTopic) { + return 'RecordNameStrategy'; + } + return 'TopicNameStrategy'; }