<commit_before>
import slick.driver.PostgresDriver
import slick.jdbc.meta.MTable
import slick.codegen.SourceCodeGenerator
import slick.driver.PostgresDriver.backend.Database
import play.api.libs.concurrent.Execution.Implicits._

import scala.concurrent.duration.Duration
import scala.concurrent.{Await, Future}

object Generator extends App {
  val slickDriver = "slick.driver.PostgresDriver"
  val jdbcDriver = "org.postgresql.Driver"
  val url = "jdbc:postgresql://localhost:5432/exampledb?searchpath=public"
  val outputDir = "./app/"
  val pkg = "generated"
  val username = "postgres"
  val password = "<PASSWORD>"

  val db = Database.forURL(url, username, password)
  val model = db.run(PostgresDriver.createModel(Some(MTable.getTables(None, None, None, Some(Seq("TABLE", "VIEW"))))))
  // customize code generator
  val codegenFuture : Future[SourceCodeGenerator] = model.map(model => new SourceCodeGenerator(model) {
    override def code = "import be.objectify.deadbolt.scala.models._\n" + super.code

    override def Table = new Table(_) {
      override def EntityType = new EntityTypeDef {
        /* This code is adapted from the `EntityTypeDef` trait's `code` method
           within `AbstractSourceCodeGenerator`.
           All code is identical except for those lines which have a corresponding
           comment above them. */
        override def code = {
          val args = columns.map(c=>
            c.default.map( v =>
              s"${c.name}: ${c.exposedType} = $v"
            ).getOrElse(
              s"${c.name}: ${c.exposedType}"
            )
          ).mkString(", ")
          if(classEnabled){
            /* `rowList` contains the names of the generated "Row" case classes we
                wish to have extend our `AutoIncEntity` trait. */
            val newParents = name match {
              case "UserRow" => parents ++ Seq("AutoIncEntity[Long, %s]".format(name))
              case "SecurityRoleRow" => parents ++ Seq("AutoIncEntity[Long, %s]".format(name), "Role")
              case "SecurityPermissionRow"  => parents ++ Seq("AutoIncEntity[Long, %s]".format(name), "Permission")
              case _ => parents
            }

            /* Use our modified parent class sequence in place of the old one. */
            val prns = (newParents.take(1).map(" extends "+_) ++ newParents.drop(1).map(" with "+_)).mkString("")
            s"""case class $name($args)$prns"""
          } else {
            s"""type $name = $types
              /** Constructor for $name providing default values if available in the database schema. */
              def $name($args): $name = {
              ${compoundValue(columns.map(_.name))}
              }
            """.trim
          }
        }
      }

      override def TableClass = new TableClassDef {
        /* This code is adapted from the `TableClassDef` trait's `code` method
           within `AbstractSourceCodeGenerator`.
           All code is identical except for those lines which have a corresponding
           comment above them. */
        override def code = {<commit_msg>Cosmetics<commit_after>
import slick.driver.PostgresDriver
import slick.jdbc.meta.MTable
import slick.codegen.SourceCodeGenerator
import slick.driver.PostgresDriver.backend.Database
import play.api.libs.concurrent.Execution.Implicits._

import scala.concurrent.duration.Duration
import scala.concurrent.{Await, Future}

object Generator extends App {
  val slickDriver = "slick.driver.PostgresDriver"
  val jdbcDriver = "org.postgresql.Driver"
  val url = "jdbc:postgresql://localhost:5432/exampledb?searchpath=public"
  val outputDir = "./app/"
  val pkg = "generated"
  val username = "postgres"
  val password = "<PASSWORD>"

  val db = Database.forURL(url, username, password)
  val model = db.run(PostgresDriver.createModel(Some(MTable.getTables(None, None, None, Some(Seq("TABLE", "VIEW"))))))
  // customize code generator
  val codegenFuture : Future[SourceCodeGenerator] = model.map(model => new SourceCodeGenerator(model) {
    override def code = "import be.objectify.deadbolt.scala.models._\n" +
                        "import dao.generic._\n" +
                        super.code

    override def Table = new Table(_) {
      override def EntityType = new EntityTypeDef {
        /* This code is adapted from the `EntityTypeDef` trait's `code` method
           within `AbstractSourceCodeGenerator`.
           All code is identical except for those lines which have a corresponding
           comment above them. */
        override def code = {
          val args = columns.map(c=>
            c.default.map( v =>
              s"${c.name}: ${c.exposedType} = $v"
            ).getOrElse(
              s"${c.name}: ${c.exposedType}"
            )
          ).mkString(", ")
          if(classEnabled){
            /* `rowList` contains the names of the generated "Row" case classes we
                wish to have extend our `EntityAutoInc` trait. */
            val newParents = name match {
              case "UserRow" => parents ++ Seq("EntityAutoInc[Long, %s]".format(name))
              case "SecurityRoleRow" => parents ++ Seq("EntityAutoInc[Long, %s]".format(name), "Role")
              case "SecurityPermissionRow"  => parents ++ Seq("EntityAutoInc[Long, %s]".format(name), "Permission")
              case _ => parents
            }

            /* Use our modified parent class sequence in place of the old one. */
            val prns = (newParents.take(1).map(" extends "+_) ++ newParents.drop(1).map(" with "+_)).mkString("")
            s"""case class $name($args)$prns"""
          } else {
            s"""type $name = $types
              /** Constructor for $name providing default values if available in the database schema. */
              def $name($args): $name = {
              ${compoundValue(columns.map(_.name))}
              }
            """.trim
          }
        }
      }

      override def TableClass = new TableClassDef {
        /* This code is adapted from the `TableClassDef` trait's `code` method
           within `AbstractSourceCodeGenerator`.
           All code is identical except for those lines which have a corresponding
           comment above them. */
        override def code = {
{'fraction_non_alphanumeric': 0.11760935747476366, 'fraction_numerical': 0.0019227687870533568, 'mean_word_length': 2.4165298303229337, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3669811', 'n_tokens_mistral': 1731, 'n_tokens_neox': 1672, 'n_words': 482}