mirror of https://github.com/Fabio286/antares.git
fix: fields default not correctly set in table filler
This commit is contained in:
parent
7ca69e51ae
commit
faa07a077c
|
@ -333,8 +333,15 @@ export class MySQLClient extends AntaresCore {
|
||||||
|
|
||||||
const details = fieldArr.slice(2).join(' ');
|
const details = fieldArr.slice(2).join(' ');
|
||||||
let defaultValue = null;
|
let defaultValue = null;
|
||||||
if (details.includes('DEFAULT'))
|
if (details.includes('DEFAULT')) {
|
||||||
defaultValue = details.match(/(?<=DEFAULT ).*?$/gs)[0].split(' COMMENT')[0];
|
defaultValue = details.match(/(?<=DEFAULT ).*?$/gs)[0].split(' COMMENT')[0];
|
||||||
|
const defaultValueArr = defaultValue.split('');
|
||||||
|
if (defaultValueArr[0] === '\'') {
|
||||||
|
defaultValueArr.shift();
|
||||||
|
defaultValueArr.pop();
|
||||||
|
defaultValue = defaultValueArr.join('');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const typeAndLength = nameAndType[1].replace(')', '').split('(');
|
const typeAndLength = nameAndType[1].replace(')', '').split('(');
|
||||||
|
|
||||||
|
|
|
@ -252,32 +252,31 @@ export default {
|
||||||
else {
|
else {
|
||||||
if ([...NUMBER, ...FLOAT].includes(field.type))
|
if ([...NUMBER, ...FLOAT].includes(field.type))
|
||||||
fieldDefault = Number.isNaN(+field.default) ? null : +field.default;
|
fieldDefault = Number.isNaN(+field.default) ? null : +field.default;
|
||||||
|
else if ([...TEXT, ...LONG_TEXT].includes(field.type)) {
|
||||||
if ([...TEXT, ...LONG_TEXT].includes(field.type)) {
|
|
||||||
fieldDefault = field.default
|
fieldDefault = field.default
|
||||||
? field.default.includes('\'')
|
? field.default.includes('\'')
|
||||||
? field.default.split('\'')[1]
|
? field.default.split('\'')[1]
|
||||||
: field.default
|
: field.default
|
||||||
: '';
|
: '';
|
||||||
}
|
}
|
||||||
|
else if ([...TIME, ...DATE].includes(field.type))
|
||||||
if ([...TIME, ...DATE].includes(field.type))
|
|
||||||
fieldDefault = field.default;
|
fieldDefault = field.default;
|
||||||
|
else if (BIT.includes(field.type))
|
||||||
if (BIT.includes(field.type))
|
|
||||||
fieldDefault = field.default.replaceAll('\'', '').replaceAll('b', '');
|
fieldDefault = field.default.replaceAll('\'', '').replaceAll('b', '');
|
||||||
|
else if (DATETIME.includes(field.type)) {
|
||||||
if (DATETIME.includes(field.type)) {
|
if (field.default && ['current_timestamp', 'now()'].includes(field.default.toLowerCase())) {
|
||||||
if (field.default && field.default.toLowerCase().includes('current_timestamp')) {
|
|
||||||
let datePrecision = '';
|
let datePrecision = '';
|
||||||
for (let i = 0; i < field.datePrecision; i++)
|
for (let i = 0; i < field.datePrecision; i++)
|
||||||
datePrecision += i === 0 ? '.S' : 'S';
|
datePrecision += i === 0 ? '.S' : 'S';
|
||||||
fieldDefault = moment().format(`YYYY-MM-DD HH:mm:ss${datePrecision}`);
|
fieldDefault = moment().format(`YYYY-MM-DD HH:mm:ss${datePrecision}`);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
fieldDefault = field.default;
|
||||||
}
|
}
|
||||||
|
else if (field.enumValues)
|
||||||
if (field.enumValues)
|
|
||||||
fieldDefault = field.enumValues.replaceAll('\'', '').split(',');
|
fieldDefault = field.enumValues.replaceAll('\'', '').split(',');
|
||||||
|
else
|
||||||
|
fieldDefault = field.default;
|
||||||
}
|
}
|
||||||
|
|
||||||
rowObj[field.name] = { value: fieldDefault };
|
rowObj[field.name] = { value: fieldDefault };
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
v-model="optionsProxy.autoIncrement"
|
v-model="optionsProxy.autoIncrement"
|
||||||
class="form-input"
|
class="form-input"
|
||||||
type="number"
|
type="number"
|
||||||
|
:disabled="optionsProxy.autoIncrement === null"
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -284,7 +284,7 @@ export default {
|
||||||
|
|
||||||
.query-area-resizer {
|
.query-area-resizer {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
height: 5px;
|
height: 4px;
|
||||||
bottom: 40px;
|
bottom: 40px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
cursor: ns-resize;
|
cursor: ns-resize;
|
||||||
|
|
Loading…
Reference in New Issue