0

I have the following column in my postgres table:

ALTER TABLE my_table
    ALTER COLUMN test_field TYPE text ARRAY USING test_field::text ARRAY

When I regenerate the Slick schema directly from my postgres table, I have the following"

*  @param test_field Database column test_field SqlType(_text), Length(2147483647,false), Default(None) */

  case class MyTable(id: java.util.UUID, created: Option[java.sql.Timestamp] = None, test_field: Option[String] = None)

  /** GetResult implicit for fetching MyTable objects using plain SQL queries */

  implicit def GetResultTable(implicit e0: GR[java.util.UUID], e1: GR[Option[java.sql.Timestamp]], e2: GR[String] = GR{
    prs => import prs._
    MyTable(<<[java.util.UUID], <<?[java.sql.Timestamp],<<?[String])
  }

I am not sure as why the field is not recognised as Option[Array[String]] , Where did I go wrong?

Thanks

2
  • github.com/tminglei/slick-pg is a good place to start - stackoverflow.com/questions/46808137/… Commented Feb 18, 2021 at 0:10
  • Thanks, so I am now using slick-pg and created the postgresProfile exactly like the example in the Github repository, but _text is recognised as the following: ``` val test_field: Rep[Option[scala.collection.Seq]] = column[Option[scala.collection.Seq]]("test_field", O.Default(None))``` lamenting Type scala.collection.Seq takes type parameters. If I pas String as a type parameter then complains about implicit. Any idea? Commented Feb 18, 2021 at 17:26

1 Answer 1

0

I employed slick-pg and created my own MyPostgresProfile as detailed in the project's README. It turned out that there are issues with Slick dealing with text[] in Postgres and despite slick-pg does support Arrays:

[https://github.com/tminglei/slick-pg/tree/master/core/src/main/scala/com/github/tminglei/slickpg/array][1]

When generating the table, such array was actually seen as a Seq

I ended up changing the data type in Postgres from Array to jsonb and it is deal with beautifully by the plugin using JValue.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.