title: How to express Postgres arrays with Scala Slick
body: <p>I have a table in Postgres 9.5 with this structure:</p>
  
  <pre><code>my_table (id Integer, images_ranks image_rank[]);
  </code></pre>
  
  <p>where <code>image_rank</code> is:</p>
  
  <pre><code>CREATE TYPE image_rank AS (image_url text, thumbnail_rank integer);
  </code></pre>
  
  <p>I am struggling to express something like that in Slick (3.1):</p>
  
  <pre><code>case class MyTable (id: Int, imagesRanks: Seq[Option[ImageRank]])
  
  implicit val propertyMyTableResult = GetResult(r =&gt; MyTable(r.&lt;&lt;, r.&lt;&lt;)
  implicit val propertyImageRankResult = GetResult[Option[ImageRank]] { r =&gt; ImageRank(r.&lt;&lt;, r.&lt;&lt;)) }
  </code></pre>
  
  <p>What is the correct way to do it?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>This wrap (following the answer from n1r3) is blocking me at the moment:</p>
  
  <pre><code>implicit val ImageRankWrapper: JdbcType[List[ImageRank]] = new SimpleArrayJdbcType[ImageRank]("image_rank[]").to(_.toList)
  </code></pre>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>Still not sure what is wrong. I have added the code as you suggested, but it still complains with: </p>
  
  <p><code>could not find implicit value for parameter rconv: slick.jdbc.GetResult[database.rows.MyTable]</code>. </p>
  
  <p>So I have added:</p>
  
  <p><code>implicit val myTableResult = GetResult[MyTable](r =&gt; MyTable(r.&lt;&lt;, r.&lt;&lt;))</code></p>
  
  <p>which returns:</p>
  
  <pre><code>diverging implicit expansion for type slick.jdbc.GetResult[T1]
  starting with object GetStringOption in object GetResult
           r.&lt;&lt;, r.&lt;&lt;))
  </code></pre>
  
  <p>This is my configuration:</p>
  
  <pre><code>import com.github.tminglei.slickpg._
  import database.rows.ImageRank
  
  trait CustomPostgresProfile extends ExPostgresProfile
    with PgArraySupport
    with PgPlayJsonSupport
    with PgPostGISSupport
    with PgEnumSupport
    with PgDate2Support {
  
    // Use PostgreSQL JSONB support
    def pgjson = "jsonb"
  
    override val api = MyAPI
    object MyAPI extends API
      with ArrayImplicits
      with JsonImplicits
      with PostGISImplicits
      with DateTimeImplicits {
      implicit val imageRankListTypeMapper =
        new AdvancedArrayJdbcType[ImageRank]("image_rank",
          str =&gt; utils.SimpleArrayUtils.fromString[ImageRank](s =&gt; {
            val ImageRankRegex = "ImageRank\\((.*),(\\d+)\\)".r
            s match {
              case ImageRankRegex(imageUrl, thumbnailRank) =&gt;
                ImageRank(imageUrl, thumbnailRank.toInt)
              case _ =&gt;
                println(s"$s is not ImageRank")
                ImageRank("", 0)
            }
          })(str).orNull,
          imageRanks =&gt; utils.SimpleArrayUtils.mkString[ImageRank](_.toString)(imageRanks)
        ).to(_.toList)
    }
  }
  
  object CustomPostgresProfile extends CustomPostgresProfile
  
  
  abstract class DatabaseProfile(val provider: DatabaseConfigProvider) {
    val config = provider.get[CustomPostgresProfile]
    val profile = config.profile
    val db = config.db
  }
  
  trait PropertyDataDatabase {
      self: DatabaseProfile =&gt;
      .....
  </code></pre>