src/Pure/General/sql.scala
changeset 65668 366bc4e6a238
parent 65649 0818da4f67bb
child 65669 d2f19b4a16ae
equal deleted inserted replaced
65667:f1c70c7fea12 65668:366bc4e6a238
    35 
    35 
    36   def ident(s: String): String =
    36   def ident(s: String): String =
    37     if (Long_Name.is_qualified(s)) s
    37     if (Long_Name.is_qualified(s)) s
    38     else quote(s.replace("\"", "\"\""))
    38     else quote(s.replace("\"", "\"\""))
    39 
    39 
       
    40   def enclose(s: String): String = "(" + s + ")"
    40   def enclosure(ss: Iterable[String]): String = ss.mkString("(", ", ", ")")
    41   def enclosure(ss: Iterable[String]): String = ss.mkString("(", ", ", ")")
    41 
    42 
    42   def select(columns: List[Column], distinct: Boolean = false): String =
    43   def select(columns: List[Column], distinct: Boolean = false): String =
    43     "SELECT " + (if (distinct) "DISTINCT " else "") + commas(columns.map(_.sql)) + " FROM "
    44     "SELECT " + (if (distinct) "DISTINCT " else "") + commas(columns.map(_.sql)) + " FROM "
       
    45 
       
    46   def join(table1: Table, table2: Table, sql: String = "", outer: Boolean = false): String =
       
    47     table1.sql + (if (outer) " LEFT OUTER JOIN " else " INNER JOIN ") + table2.sql +
       
    48       (if (sql == "") "" else " ON " + sql)
       
    49 
       
    50   def join_outer(table1: Table, table2: Table, sql: String = ""): String =
       
    51     join(table1, table2, sql, outer = true)
    44 
    52 
    45 
    53 
    46   /* types */
    54   /* types */
    47 
    55 
    48   object Type extends Enumeration
    56   object Type extends Enumeration