Add the condition function by the primary key.

This commit is contained in:
shimamoto
2013-06-29 04:44:29 +09:00
parent c7d6a56ea2
commit a3133fa128
7 changed files with 14 additions and 0 deletions

View File

@@ -5,6 +5,8 @@ import scala.slick.driver.H2Driver.simple._
object Collaborators extends Table[Collaborator]("COLLABORATOR") with BasicTemplate { object Collaborators extends Table[Collaborator]("COLLABORATOR") with BasicTemplate {
def collaboratorName = column[String]("COLLABORATOR_NAME") def collaboratorName = column[String]("COLLABORATOR_NAME")
def * = userName ~ repositoryName ~ collaboratorName <> (Collaborator, Collaborator.unapply _) def * = userName ~ repositoryName ~ collaboratorName <> (Collaborator, Collaborator.unapply _)
def byPrimaryKey = byRepository _
} }
case class Collaborator( case class Collaborator(

View File

@@ -4,6 +4,7 @@ import scala.slick.driver.H2Driver.simple._
object IssueId extends Table[(String, String, Int)]("ISSUE_ID") with IssueTemplate { object IssueId extends Table[(String, String, Int)]("ISSUE_ID") with IssueTemplate {
def * = userName ~ repositoryName ~ issueId def * = userName ~ repositoryName ~ issueId
def byPrimaryKey = byRepository _
} }
object Issues extends Table[Issue]("ISSUE") with IssueTemplate with Functions { object Issues extends Table[Issue]("ISSUE") with IssueTemplate with Functions {
@@ -16,6 +17,8 @@ object Issues extends Table[Issue]("ISSUE") with IssueTemplate with Functions {
def registeredDate = column[java.util.Date]("REGISTERED_DATE") def registeredDate = column[java.util.Date]("REGISTERED_DATE")
def updatedDate = column[java.util.Date]("UPDATED_DATE") def updatedDate = column[java.util.Date]("UPDATED_DATE")
def * = userName ~ repositoryName ~ issueId ~ openedUserName ~ milestoneId.? ~ assignedUserName.? ~ title ~ content.? ~ closed ~ registeredDate ~ updatedDate <> (Issue, Issue.unapply _) def * = userName ~ repositoryName ~ issueId ~ openedUserName ~ milestoneId.? ~ assignedUserName.? ~ title ~ content.? ~ closed ~ registeredDate ~ updatedDate <> (Issue, Issue.unapply _)
def byPrimaryKey = byIssue _
} }
case class Issue( case class Issue(

View File

@@ -11,6 +11,7 @@ object IssueComments extends Table[IssueComment]("ISSUE_COMMENT") with IssueTemp
def * = userName ~ repositoryName ~ issueId ~ commentId ~ commentedUserName ~ content ~ registeredDate ~ updatedDate <> (IssueComment, IssueComment.unapply _) def * = userName ~ repositoryName ~ issueId ~ commentId ~ commentedUserName ~ content ~ registeredDate ~ updatedDate <> (IssueComment, IssueComment.unapply _)
def autoInc = userName ~ repositoryName ~ issueId ~ commentedUserName ~ content ~ registeredDate ~ updatedDate returning commentId def autoInc = userName ~ repositoryName ~ issueId ~ commentedUserName ~ content ~ registeredDate ~ updatedDate returning commentId
def byPrimaryKey(commentId: Int) = this.commentId is commentId.bind
} }
case class IssueComment( case class IssueComment(

View File

@@ -4,6 +4,8 @@ import scala.slick.driver.H2Driver.simple._
object IssueLabels extends Table[IssueLabel]("ISSUE_LABEL") with IssueTemplate with LabelTemplate { object IssueLabels extends Table[IssueLabel]("ISSUE_LABEL") with IssueTemplate with LabelTemplate {
def * = userName ~ repositoryName ~ issueId ~ labelId <> (IssueLabel, IssueLabel.unapply _) def * = userName ~ repositoryName ~ issueId ~ labelId <> (IssueLabel, IssueLabel.unapply _)
def byPrimaryKey(owner: String, repository: String, issueId: Int, labelId: Int) =
byIssue(owner, repository, issueId) && (this.labelId is labelId.bind)
} }
case class IssueLabel( case class IssueLabel(

View File

@@ -8,6 +8,7 @@ object Labels extends Table[Label]("LABEL") with LabelTemplate {
def * = userName ~ repositoryName ~ labelId ~ labelName ~ color <> (Label, Label.unapply _) def * = userName ~ repositoryName ~ labelId ~ labelName ~ color <> (Label, Label.unapply _)
def ins = userName ~ repositoryName ~ labelName ~ color def ins = userName ~ repositoryName ~ labelName ~ color
def byPrimaryKey = byLabel _
} }
case class Label( case class Label(

View File

@@ -11,6 +11,9 @@ object Milestones extends Table[Milestone]("MILESTONE") with BasicTemplate with
def * = userName ~ repositoryName ~ milestoneId ~ title ~ description.? ~ dueDate.? ~ closedDate.? <> (Milestone, Milestone.unapply _) def * = userName ~ repositoryName ~ milestoneId ~ title ~ description.? ~ dueDate.? ~ closedDate.? <> (Milestone, Milestone.unapply _)
def autoInc = userName ~ repositoryName ~ title ~ description.? ~ dueDate.? ~ closedDate.? returning milestoneId def autoInc = userName ~ repositoryName ~ title ~ description.? ~ dueDate.? ~ closedDate.? returning milestoneId
// TODO create a template?
def byPrimaryKey(owner: String, repository: String, milestoneId: Int) =
byRepository(owner, repository) && (this.milestoneId is milestoneId.bind)
} }
case class Milestone( case class Milestone(

View File

@@ -10,6 +10,8 @@ object Repositories extends Table[Repository]("REPOSITORY") with BasicTemplate w
def updatedDate = column[java.util.Date]("UPDATED_DATE") def updatedDate = column[java.util.Date]("UPDATED_DATE")
def lastActivityDate = column[java.util.Date]("LAST_ACTIVITY_DATE") def lastActivityDate = column[java.util.Date]("LAST_ACTIVITY_DATE")
def * = userName ~ repositoryName ~ isPrivate ~ description.? ~ defaultBranch ~ registeredDate ~ updatedDate ~ lastActivityDate <> (Repository, Repository.unapply _) def * = userName ~ repositoryName ~ isPrivate ~ description.? ~ defaultBranch ~ registeredDate ~ updatedDate ~ lastActivityDate <> (Repository, Repository.unapply _)
def byPrimaryKey = byRepository _
} }
case class Repository( case class Repository(