--- a/src/main/scala/SQL.scala Sat Feb 27 08:46:18 2010 -0500
+++ b/src/main/scala/SQL.scala Sat Feb 27 11:00:11 2010 -0500
@@ -16,45 +16,45 @@
sealed abstract class RelationORSubselect
case class Subselect(sel:SelectORUnion) extends RelationORSubselect {
- def toString999 = "(\n " + sel.toString.replace("\n", "\n ") + "\n )"
+ override def toString = "(\n " + sel.toString.replace("\n", "\n ") + "\n )"
}
sealed abstract class SelectORUnion
case class Select(attributelist:AttributeList, tablelist:TableList, expression:Option[Expression]) extends SelectORUnion {
- def toString999 = expression match {
+ override def toString = expression match {
case Some(expr) => attributelist+"\n"+tablelist+"\n WHERE "+expr
case None => attributelist+"\n"+tablelist
}
}
case class Relation(n:Name) extends RelationORSubselect {
- def toString999 = n.s /* "'" + n.s + "'" */
+ override def toString = n.s /* "'" + n.s + "'" */
}
case class Union(disjoints:Set[Select]) extends SelectORUnion {
- def toString999 = " " + (disjoints.toList.map(s => s.toString.replace("\n", "\n ")).mkString("\nUNION\n "))
+ override def toString = " " + (disjoints.toList.map(s => s.toString.replace("\n", "\n ")).mkString("\nUNION\n "))
}
case class AttributeList(attributes:Set[NamedAttribute]) {
// foo, bar
- def toString999 = "SELECT "+(attributes.toList.sortWith((l, r) => l.attralias.toString < r.attralias.toString).mkString(", "))
+ override def toString = "SELECT "+(attributes.toList.sortWith((l, r) => l.attralias.toString < r.attralias.toString).mkString(", "))
}
case class NamedAttribute(value:RelVarAttrORExpression, attralias:AttrAlias) {
- def toString999 = value + " AS " + attralias
+ override def toString = value + " AS " + attralias
}
//case class RelAttribute(relation:Relation, attribute:Attribute) c.f. ForeignKey
sealed abstract class RelVarAttrORExpression
case class RelVarAttr(relvar:RelVar, attribute:Attribute) extends RelVarAttrORExpression {
- def toString999 = relvar + "." + attribute
+ override def toString = relvar + "." + attribute
}
case class Attribute(n:Name) {
- def toString999 = n.s /* "'" + n.s + "'" */
+ override def toString = n.s /* "'" + n.s + "'" */
}
case class AttrAlias(n:Name) {
- def toString999 = n.s /* "'" + n.s + "'" */
+ override def toString = n.s /* "'" + n.s + "'" */
}
case class RelVar(n:Name) {
- def toString999 = n.s /* "'" + n.s + "'" */
+ override def toString = n.s /* "'" + n.s + "'" */
}
case class TableList(joins:AddOrderedSet[Join]) {
- def toString999 =
+ override def toString =
if (joins.size == 0) ""
else {
" FROM " + joins.foldLeft(("", 0))(
@@ -67,25 +67,25 @@
sealed abstract class Join(res:AliasedResource)
case class InnerJoin(res:AliasedResource, optOn:Option[Expression]) extends Join(res) {
- def toString999 = "\n INNER JOIN " + res
+ override def toString = "\n INNER JOIN " + res
}
case class LeftOuterJoin(res:AliasedResource, on:Expression) extends Join(res) {
- def toString999 = "\n LEFT OUTER JOIN " + res + " ON " + on
+ override def toString = "\n LEFT OUTER JOIN " + res + " ON " + on
}
case class AliasedResource(rel:RelationORSubselect, as:RelVar) {
- def toString999 = rel + " AS " + as
+ override def toString = rel + " AS " + as
}
sealed abstract class Expression extends RelVarAttrORExpression
case class ExprConjunction(exprs:Set[Expression]) extends Expression {
- def toString999 = "(" + (exprs.toList.sortWith((l, r) => l.toString < r.toString).mkString (")\n AND (")) + ")"
+ override def toString = "(" + (exprs.toList.sortWith((l, r) => l.toString < r.toString).mkString (")\n AND (")) + ")"
}
case class ExprDisjunction(exprs:Set[Expression]) extends Expression {
- def toString999 = "(" + (exprs mkString (") OR (")) + ")"
+ override def toString = "(" + (exprs mkString (") OR (")) + ")"
}
sealed abstract class RelationalExpression extends Expression
case class RelationalExpressionEq(l:Expression, r:Expression) extends RelationalExpression {
- def toString999 = l + "=" + r
+ override def toString = l + "=" + r
/* safer operator== , but doesn't quite work yet. */
// override def hashCode = 41 * l.hashCode + r.hashCode
// override def equals(other: Any) = other match {
@@ -111,36 +111,36 @@
l.hashCode + r.hashCode
}
case class RelationalExpressionNe(l:Expression, r:Expression) extends RelationalExpression {
- def toString999 = l + "!=" + r
+ override def toString = l + "!=" + r
}
case class RelationalExpressionLt(l:Expression, r:Expression) extends RelationalExpression {
- def toString999 = l + "<" + r
+ override def toString = l + "<" + r
}
case class RelationalExpressionNull(l:Expression) extends RelationalExpression { // Expression?
- def toString999 = l + " IS NULL"
+ override def toString = l + " IS NULL"
}
case class RelationalExpressionNotNull(l:Expression) extends RelationalExpression { // Expression?
- def toString999 = l + " IS NOT NULL"
+ override def toString = l + " IS NOT NULL"
}
sealed abstract class PrimaryExpression extends Expression
case class PrimaryExpressionAttr(fqattribute:RelVarAttr) extends PrimaryExpression {
- def toString999 = "" + fqattribute
+ override def toString = "" + fqattribute
}
case class PrimaryExpressionTyped(datatype:Datatype, i:Name) extends PrimaryExpression {
- def toString999 = /* "'" + i.s + "'" */ /* + datatype */
+ override def toString = /* "'" + i.s + "'" */ /* + datatype */
datatype match {
case Datatype("Int") => i.s
case _ => "\"" + i.s + "\""
}
}
case class ConstNULL() extends PrimaryExpression {
- def toString999 = "NULL"
+ override def toString = "NULL"
}
case class Concat(args:List[Expression]) extends PrimaryExpression {
- def toString999 = args.mkString("CONCAT(", ", ", ")")
+ override def toString = args.mkString("CONCAT(", ", ", ")")
}
case class IfElse(cond:Expression, pass:Expression, fail:Expression) extends PrimaryExpression {
- def toString999 = "CONCAT(" + cond + ", " + pass + ", " + fail + ")"
+ override def toString = "CONCAT(" + cond + ", " + pass + ", " + fail + ")"
}
case class Name(s:String)
@@ -150,7 +150,7 @@
}
case class Datatype(name:String) {
- def toString999 = "/* " + name + " */"
+ override def toString = "/* " + name + " */"
}
object Datatype {
val STRING = Datatype("String")