Effect CommunityEC
Effect Community9mo ago
12 replies
rpiotrow

ParseError with DateTime Fields in PostgreSQL Using Effect-TS

Anyone familiar with this kind of error when using PostgreSQL?
  ParseError: (User (Encoded side) <-> User)
  └─ Encoded side transformation failure
     └─ User (Encoded side)
        └─ ["createdAt"]
           └─ DateTimeUtc
              └─ Encoded side transformation failure
                 └─ Expected string, actual 2025-04-29T06:53:46.594Z


I'm using https://github.com/Effect-TS/examples/tree/main/examples/http-server but with PostgreSQL instead of SqlLite
Entity looks like that:
export class Account extends Model.Class<Account>("Account")({
  id: Model.Generated(AccountId),
  createdAt: Model.DateTimeInsert,
  updatedAt: Model.DateTimeUpdate
}) {}

I also tried DateTimeInsertFromDate and DateTimeUpdateFromDate but does not work as well. Sql is:
      CREATE TABLE "accounts" (
        "id" SERIAL PRIMARY KEY,
        "createdAt" TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
        "updatedAt" TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL
      )

Also tried with TIMESTAMPTZ and with no default, does now work as well
Was this page helpful?