1
1
mirror of https://github.com/Fabio286/antares.git synced 2025-06-05 21:59:22 +02:00

feat(Firebird SQL): table add/edit/delete support

This commit is contained in:
2022-11-15 16:46:12 +01:00
parent 27566c1dfa
commit 1b5cc315dd
20 changed files with 241 additions and 200 deletions

View File

@ -531,9 +531,10 @@ const clearChanges = () => {
};
const addField = () => {
const uid = uidGen();
localFields.value.push({
_antares_id: uidGen(),
name: `${t('word.field', 1)}_${++newFieldsCounter.value}`,
_antares_id: uid,
name: `${t('word.field', 1)}_${uid.substring(0, 4)}`,
key: '',
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type: (workspace.value.dataTypes[0] as any).types[0].name,

View File

@ -113,7 +113,7 @@
</div>
</div>
<div class="form-group">
<label class="form-label col-3 pt-0">
<label class="form-label col-3">
{{ t('message.referenceTable') }}
</label>
<div class="column">
@ -219,13 +219,8 @@ const foreignProxy = ref([]);
const selectedForeignID = ref('');
const modalInnerHeight = ref(400);
const refFields = ref({} as {[key: string]: TableField[]});
const foreignActions = [
'RESTRICT',
'CASCADE',
'SET NULL',
'NO ACTION'
];
const foreignActions = computed(() => props.workspace.customizations.foreignActions);
const selectedForeignObj = computed(() => foreignProxy.value.find(foreign => foreign._antares_id === selectedForeignID.value));
const isChanged = computed(() => JSON.stringify(props.localKeyUsage) !== JSON.stringify(foreignProxy.value));
@ -254,16 +249,17 @@ const getModalInnerHeight = () => {
};
const addForeign = () => {
const uid = uidGen();
foreignProxy.value = [...foreignProxy.value, {
_antares_id: uidGen(),
constraintName: `FK_${uidGen()}`,
_antares_id: uid,
constraintName: `FK_${uid.substring(0, 4)}`,
refSchema: props.schema,
table: props.table,
refTable: '',
field: '',
refField: '',
onUpdate: foreignActions[0],
onDelete: foreignActions[0]
onUpdate: foreignActions.value[0],
onDelete: foreignActions.value[0]
}];
if (foreignProxy.value.length === 1)
@ -271,6 +267,7 @@ const addForeign = () => {
setTimeout(() => {
indexesPanel.value.scrollTop = indexesPanel.value.scrollHeight + 60;
selectedForeignID.value = uid;
}, 20);
};

View File

@ -92,7 +92,7 @@
<BaseSelect
v-model="selectedIndexObj.type"
:options="indexTypes"
:option-disabled="(opt: any) => opt === 'PRIMARY'"
:option-disabled="(opt: any) => opt === 'PRIMARY' && hasPrimary"
class="form-select"
/>
</div>
@ -160,6 +160,7 @@ const modalInnerHeight = ref(400);
const selectedIndexObj = computed(() => indexesProxy.value.find(index => index._antares_id === selectedIndexID.value));
const isChanged = computed(() => JSON.stringify(props.localIndexes) !== JSON.stringify(indexesProxy.value));
const hasPrimary = computed(() => indexesProxy.value.some(index => ['PRIMARY', 'PRIMARY KEY'].includes(index.type)));
const confirmIndexesChange = () => {
indexesProxy.value = indexesProxy.value.filter(index => index.fields.length);
@ -179,15 +180,12 @@ const getModalInnerHeight = () => {
};
const addIndex = () => {
const uid = uidGen();
indexesProxy.value = [...indexesProxy.value, {
_antares_id: uidGen(),
name: 'NEW_INDEX',
_antares_id: uid,
name: `INDEX_${uid.substring(0, 4)}`,
fields: [],
type: 'INDEX',
comment: '',
indexType: 'BTREE',
indexComment: '',
cardinality: 0
type: props.workspace.customizations.primaryAsIndex ? props.indexTypes[0] : props.indexTypes[1]
}];
if (indexesProxy.value.length === 1)
@ -195,6 +193,7 @@ const addIndex = () => {
setTimeout(() => {
indexesPanel.value.scrollTop = indexesPanel.value.scrollHeight + 60;
selectedIndexID.value = uid;
}, 20);
};

View File

@ -501,8 +501,8 @@ const editOFF = () => {
localRow.value.enumValues = '';
if (fieldType.value.length) {
if (['integer', 'float', 'binary', 'spatial'].includes(fieldType.value.group)) localRow.value.numLength = 11;
if (['string'].includes(fieldType.value.group)) localRow.value.charLength = 15;
if (['integer', 'float', 'binary', 'spatial'].includes(fieldType.value.group)) localRow.value.numLength = 10;
if (['string'].includes(fieldType.value.group)) localRow.value.charLength = 20;
if (['time'].includes(fieldType.value.group)) localRow.value.datePrecision = 0;
if (['other'].includes(fieldType.value.group)) localRow.value.enumValues = '\'valA\',\'valB\'';
}

View File

@ -271,7 +271,7 @@ const keyName = (key: string) => {
case 'mul':
return 'INDEX';
case 'fk':
return 'FOREIGN KEY';
return 'REFERENCES';
default:
return 'UNKNOWN ' + key;
}