mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
fix: unable to add new ENUM fields
This commit is contained in:
@ -309,6 +309,25 @@ export class MySQLClient extends AntaresCore {
|
|||||||
.orderBy({ ORDINAL_POSITION: 'ASC' })
|
.orderBy({ ORDINAL_POSITION: 'ASC' })
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
|
// const { rows } = await this.raw(`SHOW CREATE TABLE ${schema}.${table}`);
|
||||||
|
|
||||||
|
// const fields = rows.map(row => {
|
||||||
|
// let n = 0;
|
||||||
|
// return row['Create Table']
|
||||||
|
// .split('')
|
||||||
|
// .reduce((acc, curr) => {
|
||||||
|
// if (curr === ')') n--;
|
||||||
|
// if (n !== 0) acc += curr;
|
||||||
|
// if (curr === '(') n++;
|
||||||
|
// return acc;
|
||||||
|
// }, '')
|
||||||
|
// .replaceAll('\n', '')
|
||||||
|
// .split(',')
|
||||||
|
// .map(f => {
|
||||||
|
// return f.trim();// TODO: here map the field
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
|
||||||
return rows.map(field => {
|
return rows.map(field => {
|
||||||
let numLength = field.COLUMN_TYPE.match(/int\(([^)]+)\)/);
|
let numLength = field.COLUMN_TYPE.match(/int\(([^)]+)\)/);
|
||||||
numLength = numLength ? +numLength.pop() : null;
|
numLength = numLength ? +numLength.pop() : null;
|
||||||
@ -1084,7 +1103,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
// ADD FIELDS
|
// ADD FIELDS
|
||||||
additions.forEach(addition => {
|
additions.forEach(addition => {
|
||||||
const typeInfo = this._getTypeInfo(addition.type);
|
const typeInfo = this._getTypeInfo(addition.type);
|
||||||
const length = typeInfo.length ? addition.numLength || addition.charLength || addition.datePrecision : false;
|
const length = typeInfo.length ? addition.enumValues || addition.numLength || addition.charLength || addition.datePrecision : false;
|
||||||
|
|
||||||
alterColumns.push(`ADD COLUMN \`${addition.name}\`
|
alterColumns.push(`ADD COLUMN \`${addition.name}\`
|
||||||
${addition.type.toUpperCase()}${length ? `(${length})` : ''}
|
${addition.type.toUpperCase()}${length ? `(${length})` : ''}
|
||||||
|
@ -96,8 +96,13 @@
|
|||||||
class="cell-content"
|
class="cell-content"
|
||||||
@dblclick="editON($event, localLength, 'length')"
|
@dblclick="editON($event, localLength, 'length')"
|
||||||
>
|
>
|
||||||
|
<span v-if="localRow.enumValues">
|
||||||
|
{{ localRow.enumValues }}
|
||||||
|
</span>
|
||||||
|
<span v-else>
|
||||||
{{ localLength }}
|
{{ localLength }}
|
||||||
</span>
|
</span>
|
||||||
|
</span>
|
||||||
<input
|
<input
|
||||||
v-else-if="localRow.enumValues"
|
v-else-if="localRow.enumValues"
|
||||||
ref="editField"
|
ref="editField"
|
||||||
@ -361,7 +366,7 @@ export default {
|
|||||||
getWorkspace: 'workspaces/getWorkspace'
|
getWorkspace: 'workspaces/getWorkspace'
|
||||||
}),
|
}),
|
||||||
localLength () {
|
localLength () {
|
||||||
return this.localRow.enumValues || this.localRow.numLength || this.localRow.charLength || this.localRow.datePrecision || this.localRow.numPrecision || 0;
|
return this.localRow.numLength || this.localRow.charLength || this.localRow.datePrecision || this.localRow.numPrecision || 0;
|
||||||
},
|
},
|
||||||
fieldType () {
|
fieldType () {
|
||||||
const fieldType = this.dataTypes.reduce((acc, group) => [...acc, ...group.types], []).filter(type =>
|
const fieldType = this.dataTypes.reduce((acc, group) => [...acc, ...group.types], []).filter(type =>
|
||||||
|
Reference in New Issue
Block a user