Skip to content

Commit

Permalink
fix(MySQL): default value not displayed for DECIMAL fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio286 committed Feb 5, 2022
1 parent 2c7c978 commit fa3f3e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/common/data-types/mysql.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ module.exports = [
{
name: 'JSON',
length: false,
collation: true,
collation: false,
unsigned: false,
zerofill: false
}
Expand Down
8 changes: 6 additions & 2 deletions src/main/libs/clients/MySQLClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ export class MySQLClient extends AntaresCore {
return acc;
}, '')
.replaceAll('\n', '')
.split(',')
.split(/,\s?(?![^(]*\))/)
.map(f => {
try {
const fieldArr = f.trim().split(' ');
Expand Down Expand Up @@ -440,6 +440,10 @@ export class MySQLClient extends AntaresCore {
? field.COLUMN_TYPE.match(/\(([^)]+)\)/)[0].slice(1, -1)
: null;

const defaultValue = (remappedFields && remappedFields[field.COLUMN_NAME])
? remappedFields[field.COLUMN_NAME].default
: field.COLUMN_DEFAULT;

return {
name: field.COLUMN_NAME,
key: field.COLUMN_KEY.toLowerCase(),
Expand All @@ -458,7 +462,7 @@ export class MySQLClient extends AntaresCore {
unsigned: field.COLUMN_TYPE.includes('unsigned'),
zerofill: field.COLUMN_TYPE.includes('zerofill'),
order: field.ORDINAL_POSITION,
default: (remappedFields && remappedFields[field.COLUMN_NAME]) ? remappedFields[field.COLUMN_NAME].default : field.COLUMN_DEFAULT,
default: defaultValue,
charset: field.CHARACTER_SET_NAME,
collation: field.COLLATION_NAME,
autoIncrement: field.EXTRA.includes('auto_increment'),
Expand Down

0 comments on commit fa3f3e1

Please sign in to comment.