nafg / slick-migration-api

Schema manipulation dialects and DSL for Slick

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Invalid column type generation of autoincremental bigint for PostgresDialect.

ariel201286 opened this issue · comments

Invalid column type generation of autoincremental bigint for PostgresDialect.

Hi, can you provide all the relevant details please?

This is the example code:
class Coffees(tag: Tag) extends Table(Long, String, Double) {
def id = column[Long]("ID", O.PrimaryKey, O.AutoInc)
def name = columnString
def price = columnDouble
def * = (name, supID, price, sales, total)
}

val cofeeRows = TableQuery[Coffees]

TableMigration(cofeeRows)
.create
.addColumns(_.id, _.name, _.price)

The id column of the generated table should be BIGSERIAL, instead it is generated as SERIAL.

The problem is in columType method of PostgresDialect class. It is easy to fix. A posible solution may be:

override def columnType(ci: ColumnInfo): String = {
if (ci.autoInc) {
ci.sqlType.toUpperCase match {
case "BIGINT" => "BIGSERIAL"
case _ => "SERIAL"
}
} else {
ci.sqlType
}
}

Thanks. Can you make a pull request?

Yes, as soon as possible.