Giter Site home page Giter Site logo

entitytled's People

Contributors

rsschermer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

lengvarsky

entitytled's Issues

Eager-loading without runtime reflection

Eager-loading currently depends on Entity#withIncludes, which is currently implemented through runtime reflection. This is not ideal, neither for performance, nor for runtime safety.

Eliminate TableQuery boilerplate for EntityCompanions

It's currently not possible to use TableQuery[EntityTable] with a generic EntityTable type, because a concrete type parameter is necessary (see http://stackoverflow.com/questions/20090228/how-to-define-generic-type-in-scala).

If a way to achieve a generic TableQuery or something similar could be found, this:

object Director extends EntityCompanion[Directors, Director] {
  val query = TableQuery[Directors]
}

Could be reduced to:

object Director extends EntityCompanion[Directors, Director]

Relationship defaults macros don't work in cake

Given the following 2 components:

trait DirectorComponent {
  self: Entitytled =>

  import driver.api._

  case class Director(
      id: Option[Long],
      name: String,
      age: Int)
    extends Entity[Director, Long]

  object Director extends EntityCompanion[Directors, Director, Long]

  class Directors(tag: Tag) extends EntityTable[Director, Long](tag, "DIRECTORS") {
    def id = column[Long]("id", O.PrimaryKey, O.AutoInc)
    def name = column[String]("name")
    def age = column[Int]("age")

    def * = (id.?, name) <> ((Director.apply _).tupled, Director.unapply)
  }
}

trait MovieComponent {
  self: Entitytled with DirectorComponent =>

  import driver.api._

  case class Movie(
      id: Option[Long],
      title: String,
      directorID: Long)(implicit includes: Includes[Movie])
    extends Entity[Movie, Long]
  {
    val director = one(Movie.director)
  }

  object Movie extends EntityCompanion[Movies, Movie, Long] {
    val director = toOne[Directors, Director]
  }

  class Movies(tag: Tag) extends EntityTable[Movie, Long](tag, "MOVIES") {
    def id = column[Long]("id", O.PrimaryKey, O.AutoInc)
    def title = column[String]("title")
    def directorID = column[Long]("director_id")

    def * = (id.?, title, directorID) <> ((Movie.apply _).tupled, Movie.unapply)

    def director = foreignKey("MOVIES_DIRECTOR_FK", directorID, TableQuery[Directors])(_.id)
  }
}

The compiler fails to resolve an implicit TableQueryProvider[MovieComponent.this.Directors, MovieComponent.this.Director] (which it needs in order to create a default target query for the toOne relationship defined on the Movie companion). The reason for this seems to be that the macro implementation that instantiates the TableQueryProvider expands to a type of TableQueryProvider[DirectorComponent.this.Directors, DirectorComponent.this.Director], even though the type parameters passed to the macro method seem to be MovieComponent.this.Directors and MovieComponent.this.Director.

See also some experimentation here: https://github.com/RSSchermer/cake-macro-test

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.