mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-18 14:16:48 +00:00
fix: fixing key-value after adding version (#3093)
This commit is contained in:
parent
01bc0e8e4c
commit
c13d83b5c5
@ -1,4 +1,4 @@
|
||||
import translateFieldPath from '../schema/utils/translateFieldPath';
|
||||
import translateFieldPath from '../../schema/utils/translateFieldPath';
|
||||
|
||||
describe('translateFieldPath', () => {
|
||||
it('translates qualified unions', () => {
|
@ -1,4 +1,4 @@
|
||||
import translateFieldPathSegment from '../schema/utils/translateFieldPathSegment';
|
||||
import translateFieldPathSegment from '../../schema/utils/translateFieldPathSegment';
|
||||
|
||||
describe('translateFieldPathSegment', () => {
|
||||
it('translates unions', () => {
|
@ -0,0 +1,49 @@
|
||||
import { SchemaFieldDataType } from '../../../../../../types.generated';
|
||||
import { filterKeyFieldPath } from '../../schema/utils/utils';
|
||||
|
||||
describe('utils', () => {
|
||||
describe('filterKeyFieldPath', () => {
|
||||
it('allows keys when looking for keys', () => {
|
||||
expect(
|
||||
filterKeyFieldPath(true, {
|
||||
fieldPath: '[version=2.0].[key=True].[type=long].field',
|
||||
nullable: false,
|
||||
type: SchemaFieldDataType.Number,
|
||||
recursive: false,
|
||||
}),
|
||||
).toEqual(true);
|
||||
});
|
||||
it('blocks non-keys when looking for keys', () => {
|
||||
expect(
|
||||
filterKeyFieldPath(true, {
|
||||
fieldPath: '[version=2.0].[type=long].field',
|
||||
nullable: false,
|
||||
type: SchemaFieldDataType.Number,
|
||||
recursive: false,
|
||||
}),
|
||||
).toEqual(false);
|
||||
});
|
||||
|
||||
it('allows non-keys when looking for non-keys', () => {
|
||||
expect(
|
||||
filterKeyFieldPath(false, {
|
||||
fieldPath: '[version=2.0].[type=long].field',
|
||||
nullable: false,
|
||||
type: SchemaFieldDataType.Number,
|
||||
recursive: false,
|
||||
}),
|
||||
).toEqual(true);
|
||||
});
|
||||
|
||||
it('blocks keys when looking for non-keys', () => {
|
||||
expect(
|
||||
filterKeyFieldPath(false, {
|
||||
fieldPath: '[version=2.0].[key=True].[type=long].field',
|
||||
nullable: false,
|
||||
type: SchemaFieldDataType.Number,
|
||||
recursive: false,
|
||||
}),
|
||||
).toEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
@ -64,7 +64,7 @@ export default function SchemaView({
|
||||
});
|
||||
|
||||
const hasKeySchema = useMemo(
|
||||
() => (schema?.fields?.findIndex((field) => field.fieldPath.startsWith(KEY_SCHEMA_PREFIX)) || -1) !== -1,
|
||||
() => (schema?.fields?.findIndex((field) => field.fieldPath.indexOf(KEY_SCHEMA_PREFIX) > -1) || -1) !== -1,
|
||||
[schema],
|
||||
);
|
||||
|
||||
|
@ -46,7 +46,7 @@ export function convertEditableSchemaMetadataForUpdate(
|
||||
}
|
||||
|
||||
export function filterKeyFieldPath(showKeySchema: boolean, field: SchemaField) {
|
||||
return field.fieldPath.startsWith(KEY_SCHEMA_PREFIX) ? showKeySchema : !showKeySchema;
|
||||
return field.fieldPath.indexOf(KEY_SCHEMA_PREFIX) > -1 ? showKeySchema : !showKeySchema;
|
||||
}
|
||||
|
||||
export function downgradeV2FieldPath(fieldPath?: string | null) {
|
||||
|
@ -206,7 +206,7 @@
|
||||
},
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "field_foo_2",
|
||||
"fieldPath": "[version=2.0].[type=boolean].field_foo_2",
|
||||
"jsonPath": null,
|
||||
"nullable": false,
|
||||
"description": {
|
||||
@ -224,7 +224,7 @@
|
||||
"recursive": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "field_bar",
|
||||
"fieldPath": "[version=2.0].[type=boolean].field_bar",
|
||||
"jsonPath": null,
|
||||
"nullable": false,
|
||||
"description": {
|
||||
@ -237,6 +237,21 @@
|
||||
},
|
||||
"nativeDataType": "boolean",
|
||||
"recursive": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "[version=2.0].[key=True].[type=int].id",
|
||||
"jsonPath": null,
|
||||
"nullable": false,
|
||||
"description": {
|
||||
"string": "Id specifying which partition the message should go to"
|
||||
},
|
||||
"type": {
|
||||
"type": {
|
||||
"com.linkedin.pegasus2avro.schema.BooleanType": {}
|
||||
}
|
||||
},
|
||||
"nativeDataType": "boolean",
|
||||
"recursive": false
|
||||
}
|
||||
],
|
||||
"primaryKeys": null,
|
||||
|
Loading…
x
Reference in New Issue
Block a user