This commit is contained in:
Jan Prochazka
2020-06-18 21:18:30 +02:00
parent ac9bd62ecf
commit cecb88f024
13 changed files with 90 additions and 234 deletions

View File

@@ -22,6 +22,7 @@
},
"dependencies": {
"@types/parsimmon": "^1.10.1",
"@dbgate/tools": "^0.1.0",
"lodash": "^4.17.15",
"moment": "^2.24.0",
"parsimmon": "^1.13.0"

View File

@@ -1,19 +1,11 @@
import { DbTypeCode } from '@dbgate/types';
import { isTypeNumber, isTypeString, isTypeLogical, isTypeDateTime } from '@dbgate/tools';
import { FilterType } from './types';
export function getFilterType(typeCode?: DbTypeCode): FilterType {
if (!typeCode) return 'string';
switch (typeCode) {
case 'int':
case 'numeric':
case 'float':
return 'number';
case 'string':
return 'string';
case 'datetime':
return 'datetime';
case 'logical':
return 'logical';
}
export function getFilterType(dataType: string): FilterType {
if (!dataType) return 'string';
if (isTypeNumber(dataType)) return 'number';
if (isTypeString(dataType)) return 'string';
if (isTypeLogical(dataType)) return 'logical';
if (isTypeDateTime(dataType)) return 'datetime';
return 'string';
}