Skip to content

feat: parse decimal#591

Open
kulikp1 wants to merge 8 commits intonextfrom
feature/AdminForth/1506/we-should-not-render-so-many-z
Open

feat: parse decimal#591
kulikp1 wants to merge 8 commits intonextfrom
feature/AdminForth/1506/we-should-not-render-so-many-z

Conversation

@kulikp1
Copy link
Copy Markdown
Collaborator

@kulikp1 kulikp1 commented Apr 30, 2026

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Postgres connector’s type parsing to support a new DECIMAL/NUMERIC field (e.g., the test_decimal field mentioned in the PR title) by customizing how values are returned from pg.

Changes:

  • Added a pg OID 1700 (NUMERIC/DECIMAL) type parser in the Postgres connector.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread adminforth/dataConnectors/postgres.ts Outdated
// which treats them as LOCAL server time. Return raw strings so getFieldValue can parse as UTC.
types.setTypeParser(1114, (val) => val); // TIMESTAMP WITHOUT TIME ZONE
types.setTypeParser(1082, (val) => val); // DATE
types.setTypeParser(1700, (val) => val === null ? null : parseFloat(val).toString()); // NUMERIC/DECIMAL
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The NUMERIC/DECIMAL type parser uses parseFloat(val).toString(), which will lose precision for many valid Postgres NUMERIC values (and also strips trailing zeros, potentially changing the intended scale, e.g. '1.00' -> '1'). Since this connector already models DECIMAL separately (AdminForthDataTypes.DECIMAL) and pg returns NUMERIC as a string by default, consider returning the raw string (like the timestamp/date parsers) or using a decimal library / scale-aware formatting if numeric normalization is required.

Suggested change
types.setTypeParser(1700, (val) => val === null ? null : parseFloat(val).toString()); // NUMERIC/DECIMAL
// Preserve exact NUMERIC/DECIMAL values as returned by pg to avoid precision and scale loss.
types.setTypeParser(1700, (val) => val); // NUMERIC/DECIMAL

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we have to search another approach

@kulikp1 kulikp1 changed the title feat: add test_decimal field to cars model and update related resources feat: parse decimal May 1, 2026
Comment thread adminforth/dataConnectors/postgres.ts Outdated
Comment thread adminforth/dataConnectors/postgres.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants