Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Distinct can confuse columnsΒ #3146

@OlegYch

Description

@OlegYch
  def testDistinctManyColumns = {
    case class AA(from: String, to: String, data: Int)
    case class T(table: String)(tag: Tag) extends Table[AA](tag, table) {
      def from = column[String]("from")
      def to = column[String]("to")
      def data = column[Int]("data")
      def * = (from, to, data).mapTo[AA]
    }
    val ts = TableQuery(T("t1"))
    val q2 = ts.distinctOn(t => (t.to, t.from)).sortBy(t => (t.to, t.from, t.data))
    val values = Seq(
      AA("from1", "to2", 1),
      AA("from1", "to1", 1),
      AA("from1", "to2", 11),
    )
    DBIO.seq(
      ts.schema.createIfNotExists,
      ts ++= values,
      q2.result.map(_ shouldBe Vector(
        AA("from1", "to1", 1),
        AA("from1", "to2", 1),
      )),
//      DBIO.failed(new Exception)
    )
  }

H2MemTest sometimes fails because columns in distinct are swapped
slick 3.6.0



This repo is using Opire - what does it mean? πŸ‘‡
πŸ’΅ Everyone can add rewards for this issue commenting /reward 100 (replace 100 with the amount).
πŸ•΅οΈβ€β™‚οΈ If someone starts working on this issue to earn the rewards, they can comment /try to let everyone know!
πŸ™Œ And when they open the PR, they can comment /claim #3146 either in the PR description or in a PR's comment.

πŸͺ™ Also, everyone can tip any user commenting /tip 20 @OlegYch (replace 20 with the amount, and @OlegYch with the user to tip).

πŸ“– If you want to learn more, check out our documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions