typelevel / typelevel/doobie

Add Meta instance to satisfy MySQL 'mediumblob' type

Open
#261 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
2.2k
Forks
379
Avg merge
14m
Merged PRs (30d)
8

Description

Using MySQL with a column type of mediumblob, running checkOutput(myQuery) yields:

[info]       + SQL Compiles and Typechecks
[info]       + C01 unixTime BIGINT        (BIGINT)     NOT NULL  →  Instant
[info]       + C02 zone     SMALLINT      (SMALLINT)   NOT NULL  →  Short
[error]       x C03 bins     LONGVARBINARY (MEDIUMBLOB) NOT NULL  →  Array[Byte]
[error]        x LONGVARBINARY (MEDIUMBLOB) is ostensibly coercible to Array[Byte] according to
[error]          the JDBC specification but is not a recommended target type. Fix this by
[error]          changing the schema type to BINARY or VARBINARY; or the Scala type to . (NarrowbandComponent.scala:52)

Creating a custom Meta mapping between Array[Byte] and LONGVARBINARY will satisfy the type checker:

implicit val ByteArrayMeta = Meta.basic[Array[Byte]](
    NonEmptyList(Binary, VarBinary, LongVarBinary),
    NonEmptyList(Binary, VarBinary, LongVarBinary),
    Nil,
    _.getBytes(_), FPS.setBytes, FRS.updateBytes
  )

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at NarrowbandComponent.scala:52 and inspect how checkOutput reports the MEDIUMBLOB to Array[Byte] mismatch. Use the proposed Meta mapping as the reference for the change, then verify that a MySQL mediumblob column typechecks as Array[Byte] without the error.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, scala
Domain
databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.