oyvindberg / typo

Typed Postgresql integration for Scala. Hopes to avoid typos

Home Page:https://oyvindberg.github.io/typo/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support to CITEXT module

KapStorm opened this issue · comments

Following the next table, I try to generate the DSL files

CREATE TABLE users(
  user_id UUID NOT NULL,
  name TEXT NOT NULL,
  last_name TEXT NULL,
  email CITEXT NOT NULL,
  password TEXT NOT NULL,
  created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
  verified_on TIMESTAMPTZ NULL,
  CONSTRAINT users_user_id_pk PRIMARY KEY (user_id),
  CONSTRAINT users_email_unique UNIQUE (email)
);

With the options

val options = Options(
      pkg = "org.foo.generated",
      dbLib = Some(DbLibName.Anorm),
      jsonLibs = List(JsonLibName.PlayJson),
      enableDsl = true
    )

When generating the DSL files, the script logs Couldn't translate type from relation public.users column email with type email. Falling back to text generating the UsersRepoImpl, but if I do a select, Anorm throws the error

  println(UsersRepoImpl.selectAll)
Exception in thread "main" java.lang.ExceptionInInitializerError
        at Main.main(Main.scala)
Caused by: anorm.AnormException: TypeDoesNotMatch(Cannot convert email@email.net: org.postgresql.util.PGobject to String for column ColumnName(users.email,Some(email)))

I'm using scala-cli with libs

//> using lib "com.olvind.typo::typo:0.2.0"
//> using lib "com.olvind.typo::typo-dsl-anorm:0.2.0"
//> using lib "com.typesafe.play::play-json::2.10.0-RC9"

Hey there! Thanks for the reports.

This half-way fixed on main already. It'll patch it up and release a new version tonight 👍