Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encountering error while making query in the option type of custom column #654

Open
tishant-photon opened this issue Jul 13, 2023 · 0 comments

Comments

@tishant-photon
Copy link

tishant-photon commented Jul 13, 2023

This is my class:

case class WidgetId(id: String) extends BaseUUID
  object WidgetId extends BaseUUIDMapperImplicits[WidgetId] {
    override def prefix: String = "W"
    implicit val formats: Format[WidgetId] = formatImplicit(WidgetId(_))
    implicit val databaseMapper: BaseColumnType[WidgetId] = databaseImplicit(WidgetId(_))
  }

Database implicit method looks like this:

def databaseImplicit(f: String => T)(implicit tag: ClassTag[T]): BaseColumnType[T] =
      MappedColumnType.base[T, String](r => r.id.substring(prefix.length), r => f(prefix + r))

I created a trait:

trait PrimaryUUIDColumnMapping {
  implicit val databaseMapperWidgetId: BaseColumnType[WidgetId] = WidgetId.databaseMapper
}

Have extended this trait as mentioned in the Usage section here: https://github.com/tminglei/slick-pg.

Getting this error:
Cannot convert node to SQL Comprehension\n| Path s6._2 : Vector[t2<{s3: MappedJdbcType[ids.PrimaryUUIDs$WidgetId -> String'], s4: SOption[OptionDisc/Int]>]\n

What am I doing wrong here.

Using slick-pg 0.19.4, Tried upgrading till 0.20.4 but didn't work. Any kind of help is highly appreciated.

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

No branches or pull requests

1 participant