mirror of https://github.com/Fabio286/antares.git
refactor: number and float fields as separate types
This commit is contained in:
parent
b0576acdf6
commit
0386bbac50
|
@ -1,7 +1,8 @@
|
||||||
export const TEXT = ['CHAR', 'VARCHAR'];
|
export const TEXT = ['CHAR', 'VARCHAR'];
|
||||||
export const LONG_TEXT = ['TEXT', 'MEDIUMTEXT', 'LONGTEXT'];
|
export const LONG_TEXT = ['TEXT', 'MEDIUMTEXT', 'LONGTEXT'];
|
||||||
|
|
||||||
export const NUMBER = ['INT', 'TINYINT', 'SMALLINT', 'MEDIUMINT', 'BIGINT', 'FLOAT', 'DOUBLE', 'DECIMAL', 'BOOL'];
|
export const NUMBER = ['INT', 'TINYINT', 'SMALLINT', 'MEDIUMINT', 'BIGINT', 'DECIMAL', 'BOOL'];
|
||||||
|
export const FLOAT = ['FLOAT', 'DOUBLE'];
|
||||||
|
|
||||||
export const DATE = ['DATE'];
|
export const DATE = ['DATE'];
|
||||||
export const TIME = ['TIME'];
|
export const TIME = ['TIME'];
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { ipcMain } from 'electron';
|
import { ipcMain } from 'electron';
|
||||||
import { sqlEscaper } from 'common/libs/sqlEscaper';
|
import { sqlEscaper } from 'common/libs/sqlEscaper';
|
||||||
import { TEXT, LONG_TEXT, NUMBER, BLOB, BIT } from 'common/fieldTypes';
|
import { TEXT, LONG_TEXT, NUMBER, FLOAT, BLOB, BIT } from 'common/fieldTypes';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
|
||||||
export default (connections) => {
|
export default (connections) => {
|
||||||
|
@ -62,7 +62,7 @@ export default (connections) => {
|
||||||
let reload = false;
|
let reload = false;
|
||||||
const id = typeof params.id === 'number' ? params.id : `"${params.id}"`;
|
const id = typeof params.id === 'number' ? params.id : `"${params.id}"`;
|
||||||
|
|
||||||
if (NUMBER.includes(params.type))
|
if ([...NUMBER, ...FLOAT].includes(params.type))
|
||||||
escapedParam = params.content;
|
escapedParam = params.content;
|
||||||
else if ([...TEXT, ...LONG_TEXT].includes(params.type))
|
else if ([...TEXT, ...LONG_TEXT].includes(params.type))
|
||||||
escapedParam = `"${sqlEscaper(params.content)}"`;
|
escapedParam = `"${sqlEscaper(params.content)}"`;
|
||||||
|
@ -171,7 +171,7 @@ export default (connections) => {
|
||||||
|
|
||||||
if (params.row[key] === null)
|
if (params.row[key] === null)
|
||||||
escapedParam = 'NULL';
|
escapedParam = 'NULL';
|
||||||
else if (NUMBER.includes(type))
|
else if ([...NUMBER, ...FLOAT].includes(type))
|
||||||
escapedParam = params.row[key];
|
escapedParam = params.row[key];
|
||||||
else if ([...TEXT, ...LONG_TEXT].includes(type))
|
else if ([...TEXT, ...LONG_TEXT].includes(type))
|
||||||
escapedParam = `"${sqlEscaper(params.row[key])}"`;
|
escapedParam = `"${sqlEscaper(params.row[key])}"`;
|
||||||
|
|
|
@ -107,7 +107,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { TEXT, LONG_TEXT, NUMBER, DATE, TIME, DATETIME, BLOB, BIT } from 'common/fieldTypes';
|
import { TEXT, LONG_TEXT, NUMBER, FLOAT, DATE, TIME, DATETIME, BLOB, BIT } from 'common/fieldTypes';
|
||||||
import { mask } from 'vue-the-mask';
|
import { mask } from 'vue-the-mask';
|
||||||
import { mapGetters, mapActions } from 'vuex';
|
import { mapGetters, mapActions } from 'vuex';
|
||||||
import Tables from '@/ipc-api/Tables';
|
import Tables from '@/ipc-api/Tables';
|
||||||
|
@ -157,7 +157,7 @@ export default {
|
||||||
nInserts (val) {
|
nInserts (val) {
|
||||||
if (!val || val < 1)
|
if (!val || val < 1)
|
||||||
this.nInserts = 1;
|
this.nInserts = 1;
|
||||||
if (!val || val > 1000)
|
else if (val > 1000)
|
||||||
this.nInserts = 1000;
|
this.nInserts = 1000;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -172,7 +172,7 @@ export default {
|
||||||
|
|
||||||
if (field.default === 'NULL') fieldDefault = null;
|
if (field.default === 'NULL') fieldDefault = null;
|
||||||
else {
|
else {
|
||||||
if (NUMBER.includes(field.type))
|
if ([...NUMBER, ...FLOAT].includes(field.type))
|
||||||
fieldDefault = +field.default;
|
fieldDefault = +field.default;
|
||||||
|
|
||||||
if ([...TEXT, ...LONG_TEXT].includes(field.type))
|
if ([...TEXT, ...LONG_TEXT].includes(field.type))
|
||||||
|
@ -261,7 +261,7 @@ export default {
|
||||||
if ([...TEXT, ...LONG_TEXT].includes(field.type))
|
if ([...TEXT, ...LONG_TEXT].includes(field.type))
|
||||||
return { type: 'text', mask: false };
|
return { type: 'text', mask: false };
|
||||||
|
|
||||||
if (NUMBER.includes(field.type))
|
if ([...NUMBER, ...FLOAT].includes(field.type))
|
||||||
return { type: 'number', mask: false };
|
return { type: 'number', mask: false };
|
||||||
|
|
||||||
if (TIME.includes(field.type)) {
|
if (TIME.includes(field.type)) {
|
||||||
|
|
|
@ -135,7 +135,7 @@ import { mimeFromHex } from 'common/libs/mimeFromHex';
|
||||||
import { formatBytes } from 'common/libs/formatBytes';
|
import { formatBytes } from 'common/libs/formatBytes';
|
||||||
import { bufferToBase64 } from 'common/libs/bufferToBase64';
|
import { bufferToBase64 } from 'common/libs/bufferToBase64';
|
||||||
import hexToBinary from 'common/libs/hexToBinary';
|
import hexToBinary from 'common/libs/hexToBinary';
|
||||||
import { TEXT, LONG_TEXT, NUMBER, DATE, TIME, DATETIME, BLOB, BIT } from 'common/fieldTypes';
|
import { TEXT, LONG_TEXT, NUMBER, FLOAT, DATE, TIME, DATETIME, BLOB, BIT } from 'common/fieldTypes';
|
||||||
import { mask } from 'vue-the-mask';
|
import { mask } from 'vue-the-mask';
|
||||||
import ConfirmModal from '@/components/BaseConfirmModal';
|
import ConfirmModal from '@/components/BaseConfirmModal';
|
||||||
import ForeignKeySelect from '@/components/ForeignKeySelect';
|
import ForeignKeySelect from '@/components/ForeignKeySelect';
|
||||||
|
@ -219,7 +219,7 @@ export default {
|
||||||
if ([...TEXT, ...LONG_TEXT].includes(this.editingType))
|
if ([...TEXT, ...LONG_TEXT].includes(this.editingType))
|
||||||
return { type: 'text', mask: false };
|
return { type: 'text', mask: false };
|
||||||
|
|
||||||
if (NUMBER.includes(this.editingType))
|
if ([...NUMBER, ...FLOAT].includes(this.editingType))
|
||||||
return { type: 'number', mask: false };
|
return { type: 'number', mask: false };
|
||||||
|
|
||||||
if (TIME.includes(this.editingType)) {
|
if (TIME.includes(this.editingType)) {
|
||||||
|
|
Loading…
Reference in New Issue