summaryrefslogtreecommitdiff
path: root/src/dbc/scala/dbc/statement/JoinType.scala
blob: e5d251bcfe96dfd4eaa44efc5e347cab08b5e128 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*                     __                                               *\
**     ________ ___   / /  ___     Scala API                            **
**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
** /____/\___/_/ |_/____/_/ | |                                         **
**                          |/                                          **
\*                                                                      */

// $Id$


package scala.dbc.statement


/** A join behaviour in a <code>Jointure</code>. */
abstract class JoinType {
  /** A SQL-99 string representation of the join behaviour. */
  def sqlString: String
}

object JoinType {

  /** A join behaviour where a joined tuple is created only when a
   *  corresponding tuple exists in both original relations.
   */
  case object Inner extends JoinType {
    val sqlString = "INNER JOIN"
  }

  /** A join behaviour family where a joined tuple is created even when a
   *  tuple has no corresponding tuple in the other relation. The fields
   *  populated by values of the other tuple will receive the NULL value.
   */
  abstract class Outer extends JoinType

  object Outer {
    /** An outer join behaviour where there will be at least on tuple for
     *  every tuple in the left relation.
     */
    case object Left extends Outer {
      val sqlString = "LEFT OUTER JOIN"
    }
    /** An outer join behaviour where there will be at least on tuple for
     *  every tuple in the right relation.
     */
    case object Right extends Outer {
      val sqlString = "RIGHT OUTER JOIN"
    }
    /** An outer join behaviour where there will be at least on tuple for
     *  every tuple in both right and left relations.
     */
    case object Full extends Outer {
      val sqlString = "FULL OUTER JOIN"
    }
  }
}