diff --git a/packages/filterparser/src/filterTool.ts b/packages/filterparser/src/filterTool.ts index efab31696..3455262df 100644 --- a/packages/filterparser/src/filterTool.ts +++ b/packages/filterparser/src/filterTool.ts @@ -21,6 +21,7 @@ export function getFilterValueExpression(value, dataType?) { if (value === false) return 'FALSE'; if (value.$oid) return `ObjectId("${value.$oid}")`; if (value.$bigint) return value.$bigint; + if (value.$decimal) return value.$decimal; if (value.type == 'Buffer' && Array.isArray(value.data)) { return '0x' + arrayToHexString(value.data); } diff --git a/packages/sqltree/src/evaluateCondition.ts b/packages/sqltree/src/evaluateCondition.ts index ec5bbd2f7..f15be8053 100644 --- a/packages/sqltree/src/evaluateCondition.ts +++ b/packages/sqltree/src/evaluateCondition.ts @@ -19,6 +19,7 @@ function isLike(value, test) { function extractRawValue(value) { if (value?.$bigint) return value.$bigint; if (value?.$oid) return value.$oid; + if (value?.$decimal) return value.$decimal; return value; } diff --git a/packages/tools/src/SqlDumper.ts b/packages/tools/src/SqlDumper.ts index 9302fa368..dc767c325 100644 --- a/packages/tools/src/SqlDumper.ts +++ b/packages/tools/src/SqlDumper.ts @@ -87,6 +87,7 @@ export class SqlDumper implements AlterProcessor { this.putByteArrayValue(bytes); } else if (value?.$bigint) this.putRaw(value?.$bigint); + else if (value?.$decimal) this.putRaw(value?.$decimal); else if (_isPlainObject(value) || _isArray(value)) this.putStringValue(JSON.stringify(value)); else this.put('^null'); } diff --git a/packages/tools/src/stringTools.ts b/packages/tools/src/stringTools.ts index 0c12ac9ea..c5f24f690 100644 --- a/packages/tools/src/stringTools.ts +++ b/packages/tools/src/stringTools.ts @@ -272,6 +272,13 @@ export function stringifyCellValue( }; } + if (value?.$decimal) { + return { + value: formatCellNumber(value.$decimal, gridFormattingOptions), + gridStyle: 'valueCellStyle', + }; + } + if (editorTypes?.parseHexAsBuffer) { // if (value?.type == 'Buffer' && _isArray(value.data)) { // return { value: '0x' + arrayToHexString(value.data), gridStyle: 'valueCellStyle' }; @@ -465,6 +472,9 @@ export function shouldOpenMultilineDialog(value) { if (value?.$bigint) { return false; } + if (value?.$decimal) { + return false; + } if (_isPlainObject(value) || _isArray(value)) { return true; } @@ -715,6 +725,9 @@ export function deserializeJsTypesFromJsonParse(obj) { if (value?.$bigint) { return BigInt(value.$bigint); } + if (value?.$decimal) { + return value.$decimal; + } }); } @@ -729,6 +742,9 @@ export function deserializeJsTypesReviver(key, value) { if (value?.$bigint) { return BigInt(value.$bigint); } + if (value?.$decimal) { + return value.$decimal; + } return value; } diff --git a/packages/web/src/datagrid/DataGridCell.svelte b/packages/web/src/datagrid/DataGridCell.svelte index 585a4c081..02f7e08b2 100644 --- a/packages/web/src/datagrid/DataGridCell.svelte +++ b/packages/web/src/datagrid/DataGridCell.svelte @@ -57,7 +57,7 @@ $: style = computeStyle(maxWidth, col); $: isJson = - _.isPlainObject(value) && !(value?.type == 'Buffer' && _.isArray(value.data)) && !value.$oid && !value.$bigint; + _.isPlainObject(value) && !(value?.type == 'Buffer' && _.isArray(value.data)) && !value.$oid && !value.$bigint && !value.$decimal; // don't parse JSON for explicit data types $: jsonParsedValue = !editorTypes?.explicitDataType && isJsonLikeLongString(value) ? safeJsonParse(value) : null; diff --git a/packages/web/src/datagrid/gridutil.ts b/packages/web/src/datagrid/gridutil.ts index 6aa179509..224429767 100644 --- a/packages/web/src/datagrid/gridutil.ts +++ b/packages/web/src/datagrid/gridutil.ts @@ -73,6 +73,7 @@ export function countColumnSizes(grider: Grider, columns, containerWidth, displa if (_.isArray(value)) text = `[${value.length} items]`; else if (value?.$oid) text = `ObjectId("${value.$oid}")`; else if (value?.$bigint) text = value.$bigint; + else if (value?.$decimal) text = value.$decimal; else if (isJsonLikeLongString(value) && safeJsonParse(value)) text = '(JSON)'; const width = context.measureText(typeof text == 'string' ? text.slice(0, MAX_GRID_TEXT_LENGTH) : text).width + 8; // console.log('colName', colName, text, width); diff --git a/plugins/dbgate-plugin-postgres/src/backend/drivers.js b/plugins/dbgate-plugin-postgres/src/backend/drivers.js index 7cc58e45f..bd16ca953 100644 --- a/plugins/dbgate-plugin-postgres/src/backend/drivers.js +++ b/plugins/dbgate-plugin-postgres/src/backend/drivers.js @@ -26,8 +26,11 @@ pg.types.setTypeParser(1184, 'text', val => val); // timestamp pg.types.setTypeParser(20, 'text', val => { const parsed = parseInt(val); if (Number.isSafeInteger(parsed)) return parsed; - return BigInt(val); + return { $bigint: val }; }); // timestamp +pg.types.setTypeParser(1700, 'text', val => { + return { $decimal: val }; +}); // numeric function extractGeographyDate(value) { try {