Skip to content

fix: add support for PostgreSQL specific types (numeric, timestamptz)#9

Open
teofeo wants to merge 1 commit intoSoftwareBrothers:mainfrom
teofeo:main
Open

fix: add support for PostgreSQL specific types (numeric, timestamptz)#9
teofeo wants to merge 1 commit intoSoftwareBrothers:mainfrom
teofeo:main

Conversation

@teofeo
Copy link

@teofeo teofeo commented Mar 14, 2026

Description

Currently, the databaseTypeToAdminType converter doesn't recognize several standard PostgreSQL types. This leads to persistent console.warn messages during the discovery phase, even if types are manually overridden in resource options.

This PR adds the following mappings:

  • timestamp with time zone & timestamptz mapped to datetime.
  • numeric mapped to float.

Context & Source of the issue

When using AdonisJS (Lucid) with PostgreSQL, it is standard practice to use timezones for auditing fields and precise decimals for financial data:

// Example Migration
table.timestamp('created_at', { useTz: true })   // Resulting DB type: "timestamp with time zone"
table.decimal('latitude', 10, 8).notNullable()     // Resulting DB type: "numeric"
table.decimal('longitude', 11, 8).notNullable()  // Resulting DB type: "numeric"

Why this is necessary?

When using PostgreSQL, the adapter scans the schema and encounters these types. Since they were not explicitly defined in the switch statement, it triggered a "fallback to string" warning. Adding them ensures a cleaner console output and better default type detection for PostgreSQL users.

Changes

  • Modified src/adapter/utils/type_converter.ts to include PostgreSQL types in the switch-case logic.
  • Ensured case-insensitivity is maintained.

Visual Proof

Before (Unexpected type warnings)

Screenshot From 2026-03-14 16-17-26

After (Clean startup)

Screenshot From 2026-03-14 16-15-35

Impact

  • Cleaner Logs: Removes noisy warnings at application startup.
  • Better UX: Ensures that numeric fields are correctly identified as numbers in the AdminJS UI, enabling the appropriate input masks and validation automatically.
  • Seamless Integration: Improves the out-of-the-box experience for the AdonisJS + PostgreSQL stack.

Verification

  • Console no longer shows Unexpected type: timestamp with time zone on startup.
  • Console no longer shows Unexpected type: numeric on startup.
  • Fields are still correctly rendered as datetime and number in the AdminJS UI.

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.

1 participant