Fix manual PK using auto increment

Ref #406
This commit is contained in:
rijkvanzanten
2020-09-30 14:07:44 -04:00
parent 46ee80533e
commit d39fc483d8
2 changed files with 22 additions and 24 deletions

View File

@@ -688,6 +688,8 @@ function initLocalStore(
state.fieldData.schema.is_nullable = false;
state.fieldData.schema.default_value = false;
break;
default:
state.fieldData.schema.default_value = undefined;
}
}
);

View File

@@ -214,54 +214,50 @@ export default defineComponent({
}
function getPrimaryKeyField() {
const field: DeepPartial<Field> = {
field: primaryKeyFieldName.value,
type: 'integer',
meta: {
hidden: true,
interface: 'numeric',
readonly: true,
},
schema: {
has_auto_increment: true,
is_primary_key: true,
},
};
if (primaryKeyFieldType.value === 'uuid') {
return {
...field,
field: primaryKeyFieldName.value,
type: 'uuid',
meta: {
...field.meta,
hidden: true,
readonly: true,
interface: 'text-input',
special: ['uuid'],
},
schema: {
...field.schema,
is_primary_key: true,
length: 36,
has_auto_increment: false,
},
};
} else if (primaryKeyFieldType.value === 'manual') {
return {
...field,
field: primaryKeyFieldName.value,
type: 'string',
meta: {
...field.meta,
interface: 'text-input',
readonly: false,
hidden: false,
},
schema: {
...field.schema,
is_primary_key: true,
length: 255,
auto_increment: false,
has_auto_increment: false,
},
};
} else {
// auto_int
return field;
return {
field: primaryKeyFieldName.value,
type: 'integer',
meta: {
hidden: true,
interface: 'numeric',
readonly: true,
},
schema: {
has_auto_increment: true,
},
};
}
}
@@ -309,7 +305,7 @@ export default defineComponent({
value: 'archived',
},
],
}
},
},
schema: {
default_value: 'draft',