Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slick, UUID and Postgres

Tags:

uuid

scala

slick

I'm trying to map a java.util.UUID to a Slick column, which should be possible according to this: https://github.com/slick/slick/issues/79

I'm defining the columns as follows:

def id = column[UUID]("id", O.PrimaryKey, O.DBType("UUID"))

According to the Github issue linked above the manual DBType override should not be necessary but I couldn't get it to work without.

The error I'm getting when I'm trying to insert a row into Postgres is this:

org.postgresql.util.PSQLException: 
ERROR: column "id" is of type uuid but expression is of type bytea 

Seems that the mapping from java.util.UUID to a Postgres uuid type doesn't seem to work.

I'm using the following artifact versions:

"com.typesafe.slick" %% "slick" % "2.0.1",
"org.slf4j" % "slf4j-nop" % "1.6.4",
"org.postgresql" % "postgresql" % "9.3-1101-jdbc41"

My postgres version is $ psql --version psql (PostgreSQL) 9.3.3

What am I doing wrong?

like image 369
Leonard Ehrenfried Avatar asked Oct 02 '22 03:10

Leonard Ehrenfried


1 Answers

Looks like a bug. Please report one https://github.com/slick/slick/issues/new and refer to: https://github.com/slick/slick/issues/79 or simply re-open the latter.

UPDATE: Not a bug, but you imported the wrong driver. This happens often enough to people. Slick should catch that and provide a better error message. Here's the ticket: https://github.com/slick/slick/issues/670

like image 173
cvogt Avatar answered Oct 09 '22 16:10

cvogt