mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
filter lookups improvements
This commit is contained in:
parent
6f7452ab6d
commit
f010e7c934
@ -6,6 +6,8 @@ export type FilterMultipleValuesMode = 'is' | 'is_not' | 'contains' | 'begins' |
|
||||
export function getFilterValueExpression(value, dataType) {
|
||||
if (value == null) return 'NULL';
|
||||
if (isTypeDateTime(dataType)) return moment(value).format('YYYY-MM-DD HH:mm:ss');
|
||||
if (value === true) return 'TRUE';
|
||||
if (value === false) return 'FALSE';
|
||||
return `="${value}"`;
|
||||
}
|
||||
|
||||
|
@ -6,12 +6,12 @@ import { dumpSqlCondition } from './dumpSqlCondition';
|
||||
|
||||
export function dumpSqlSelect(dmp: SqlDumper, cmd: Select) {
|
||||
dmp.put('^select ');
|
||||
if (cmd.topRecords) {
|
||||
if (!dmp.dialect.rangeSelect || dmp.dialect.offsetFetchRangeSyntax) dmp.put('^top %s ', cmd.topRecords);
|
||||
}
|
||||
if (cmd.distinct) {
|
||||
dmp.put('^distinct ');
|
||||
}
|
||||
if (cmd.topRecords) {
|
||||
if (!dmp.dialect.rangeSelect || dmp.dialect.offsetFetchRangeSyntax) dmp.put('^top %s ', cmd.topRecords);
|
||||
}
|
||||
if (cmd.selectAll) {
|
||||
dmp.put('* ');
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
import splitterDrag from '../utility/splitterDrag';
|
||||
|
||||
import FilterMultipleValuesModal from '../modals/FilterMultipleValuesModal.svelte';
|
||||
import { getFilterValueExpression } from 'dbgate-filterparser';
|
||||
|
||||
import { showModal } from '../modals/modalTools';
|
||||
import SetFilterModal from '../modals/SetFilterModal.svelte';
|
||||
@ -223,7 +224,7 @@
|
||||
schemaName,
|
||||
pureName,
|
||||
columnName,
|
||||
onConfirm: keys => setFilter(keys.map(x => `'${x}'`).join(',')),
|
||||
onConfirm: keys => setFilter(keys.map(x => getFilterValueExpression(x)).join(',')),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@
|
||||
{
|
||||
fieldName: 'value',
|
||||
header: 'Value',
|
||||
formatter: row => row[columnName],
|
||||
formatter: row => (row[columnName] == null ? '(NULL)' : row[columnName]),
|
||||
},
|
||||
]}
|
||||
>
|
||||
|
Loading…
Reference in New Issue
Block a user