src/Pure/General/sql.scala
changeset 65774 1001fb86d7f7
parent 65748 1f4a80e80c88
child 65775 123f2c0995b8
equal deleted inserted replaced
65773:120ef768c84c 65774:1001fb86d7f7
    42     Long_Name.implode(Long_Name.explode(s).map(a => quote(a.replace("\"", "\"\""))))
    42     Long_Name.implode(Long_Name.explode(s).map(a => quote(a.replace("\"", "\"\""))))
    43 
    43 
    44   def enclose(s: Source): Source = "(" + s + ")"
    44   def enclose(s: Source): Source = "(" + s + ")"
    45   def enclosure(ss: Iterable[Source]): Source = ss.mkString("(", ", ", ")")
    45   def enclosure(ss: Iterable[Source]): Source = ss.mkString("(", ", ", ")")
    46 
    46 
    47   def select(columns: List[Column], distinct: Boolean = false): Source =
    47   def select(columns: List[Column] = Nil, distinct: Boolean = false): Source =
    48     "SELECT " + (if (distinct) "DISTINCT " else "") + commas(columns.map(_.ident)) + " FROM "
    48     "SELECT " + (if (distinct) "DISTINCT " else "") +
       
    49     (if (columns.isEmpty) "*" else commas(columns.map(_.ident))) + " FROM "
    49 
    50 
    50 
    51 
    51   /* types */
    52   /* types */
    52 
    53 
    53   object Type extends Enumeration
    54   object Type extends Enumeration
   155 
   156 
   156     def delete(sql: Source = ""): Source =
   157     def delete(sql: Source = ""): Source =
   157       "DELETE FROM " + ident +
   158       "DELETE FROM " + ident +
   158         (if (sql == "") "" else " " + sql)
   159         (if (sql == "") "" else " " + sql)
   159 
   160 
   160     def select(select_columns: List[Column], sql: Source = "", distinct: Boolean = false): Source =
   161     def select(
       
   162         select_columns: List[Column] = Nil, sql: Source = "", distinct: Boolean = false): Source =
   161       SQL.select(select_columns, distinct = distinct) + ident +
   163       SQL.select(select_columns, distinct = distinct) + ident +
   162         (if (sql == "") "" else " " + sql)
   164         (if (sql == "") "" else " " + sql)
   163 
   165 
   164     override def toString: Source = ident
   166     override def toString: Source = ident
   165   }
   167   }