Add support for PostgreSQL decimal type in filter and grid utilities

This commit is contained in:
Stela Augustinova
2025-12-08 12:52:47 +01:00
parent 2baf975847
commit e67ee4ffdb
4 changed files with 6 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ export function getFilterValueExpression(value, dataType?) {
if (value === false) return 'FALSE'; if (value === false) return 'FALSE';
if (value.$oid) return `ObjectId("${value.$oid}")`; if (value.$oid) return `ObjectId("${value.$oid}")`;
if (value.$bigint) return value.$bigint; if (value.$bigint) return value.$bigint;
if (value.$decimal) return value.$decimal;
if (value.type == 'Buffer' && Array.isArray(value.data)) { if (value.type == 'Buffer' && Array.isArray(value.data)) {
return '0x' + arrayToHexString(value.data); return '0x' + arrayToHexString(value.data);
} }

View File

@@ -19,6 +19,7 @@ function isLike(value, test) {
function extractRawValue(value) { function extractRawValue(value) {
if (value?.$bigint) return value.$bigint; if (value?.$bigint) return value.$bigint;
if (value?.$oid) return value.$oid; if (value?.$oid) return value.$oid;
if (value?.$decimal) return value.$decimal;
return value; return value;
} }

View File

@@ -472,6 +472,9 @@ export function shouldOpenMultilineDialog(value) {
if (value?.$bigint) { if (value?.$bigint) {
return false; return false;
} }
if (value?.$decimal) {
return false;
}
if (_isPlainObject(value) || _isArray(value)) { if (_isPlainObject(value) || _isArray(value)) {
return true; return true;
} }

View File

@@ -73,6 +73,7 @@ export function countColumnSizes(grider: Grider, columns, containerWidth, displa
if (_.isArray(value)) text = `[${value.length} items]`; if (_.isArray(value)) text = `[${value.length} items]`;
else if (value?.$oid) text = `ObjectId("${value.$oid}")`; else if (value?.$oid) text = `ObjectId("${value.$oid}")`;
else if (value?.$bigint) text = value.$bigint; else if (value?.$bigint) text = value.$bigint;
else if (value?.$decimal) text = value.$decimal;
else if (isJsonLikeLongString(value) && safeJsonParse(value)) text = '(JSON)'; 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; const width = context.measureText(typeof text == 'string' ? text.slice(0, MAX_GRID_TEXT_LENGTH) : text).width + 8;
// console.log('colName', colName, text, width); // console.log('colName', colName, text, width);