Skip to content

Commit 2903b89

Browse files
committed
feat: enhance decimal parsing to trim trailing zeros
1 parent 1c89c55 commit 2903b89

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

adminforth/dataConnectors/postgres.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,19 @@ class PostgresConnector extends AdminForthBaseConnector implements IAdminForthDa
214214
}
215215

216216
if (field.type === AdminForthDataTypes.DECIMAL) {
217-
const parsed = Number(value);
218-
return isNaN(parsed) ? value : parsed;
217+
if (value !== null && value !== undefined) {
218+
219+
if (value.includes('.')) {
220+
221+
let trimmed = value.replace(/0+$/, '');
222+
223+
if (trimmed.endsWith('.')) {
224+
return trimmed.slice(0, -1);
225+
}
226+
return trimmed;
227+
}
228+
}
229+
return value;
219230
}
220231

221232
if (field.type == AdminForthDataTypes.DATE) {

0 commit comments

Comments
 (0)