Skip to content

Create table from case class objects #100

@akreit

Description

@akreit

I started using scalasql and wanted to run some integration tests using testcontainers. To populate my test db, I would like to do sth like so:

case class User[T[_]](id: T[String], age: T[Int], ..... /* more fields */ )
object User extends Table[User]

val users: Seq[User] = ...

db.run(
  User.insert.batched()(users)
)

This would be more convenient than having to list all attributes in the body of batched (especially if the case class is bigger) and providing tuples for the second parameter list (although I guess the case class objects can be transformed to tuples)

A second question would be how to generate "regular" objects of type User. Since it takes a type parameter this does not seem straightforward.

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