--- a/src/test/scala/SQLTest.scala Sun Jun 13 07:42:37 2010 -0400
+++ b/src/test/scala/SQLTest.scala Sun Jun 13 09:56:13 2010 -0400
@@ -54,10 +54,12 @@
val e = """
SELECT 1 AS _TEST_
"""
- val expected = Select(AttributeList(Set(NamedAttribute(PrimaryExpressionTyped(Datatype.INTEGER,Name("1")),
- AttrAlias(Name("_TEST_"))))),
- TableList(AddOrderedSet()),
- None)
+ val expected = Select(
+ false,
+ AttributeList(Set(NamedAttribute(PrimaryExpressionTyped(Datatype.INTEGER,Name("1")),
+ AttrAlias(Name("_TEST_"))))),
+ TableList(AddOrderedSet()),
+ None, List[OrderElt](), None, None)
assert(expected === (a.parseAll(a.select, e).get))
}
@@ -70,14 +72,17 @@
INNER JOIN Employee AS R_manager
WHERE R_manager.id=R_emp.manager
"""
- val expected = Select(AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_emp")),
- Attribute(Name("lastName"))),
- AttrAlias(Name("A_empName"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None),
- InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_manager"))), None))),
- Some(
- RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("id")))),
- PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("manager")))))))
+ val expected = Select(
+ false,
+ AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_emp")),
+ Attribute(Name("lastName"))),
+ AttrAlias(Name("A_empName"))))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None),
+ InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_manager"))), None))),
+ Some(
+ RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("id")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("manager")))))),
+ List[OrderElt](), None, None)
assert(expected === (a.parseAll(a.select, e).get))
}
@@ -89,14 +94,17 @@
FROM Employee AS R_emp
INNER JOIN Employee AS R_manager ON R_manager.id=R_emp.manager
"""
- val expected = Select(AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_emp")),
- Attribute(Name("lastName"))),
- AttrAlias(Name("A_empName"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None),
- InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_manager"))), None))),
- Some(
- RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("id")))),
- PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("manager")))))))
+ val expected = Select(
+ false,
+ AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_emp")),
+ Attribute(Name("lastName"))),
+ AttrAlias(Name("A_empName"))))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None),
+ InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_manager"))), None))),
+ Some(
+ RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("id")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("manager")))))),
+ List[OrderElt](), None, None)
assert(expected === (a.parseAll(a.select, e).get))
}
@@ -109,19 +117,22 @@
INNER JOIN Employee AS R_manager
WHERE R_manager.id=R_emp.manager AND R_emp.lastName IS NOT NULL AND R_manager.lastName IS NOT NULL
"""
- val expected = Select(AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_emp")),
- Attribute(Name("lastName"))),
- AttrAlias(Name("A_empName"))),
- NamedAttribute(RelVarAttr(RelVar(Name("R_manager")),
- Attribute(Name("lastName"))),
- AttrAlias(Name("A_managName"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None),
- InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_manager"))), None))),
- Some(ExprConjunction(Set(
- RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("id")))),
- PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("manager"))))),
- RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("lastName"))))),
- RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("lastName")))))))))
+ val expected = Select(
+ false,
+ AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_emp")),
+ Attribute(Name("lastName"))),
+ AttrAlias(Name("A_empName"))),
+ NamedAttribute(RelVarAttr(RelVar(Name("R_manager")),
+ Attribute(Name("lastName"))),
+ AttrAlias(Name("A_managName"))))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None),
+ InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_manager"))), None))),
+ Some(ExprConjunction(Set(
+ RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("id")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("manager"))))),
+ RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("lastName"))))),
+ RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("lastName")))))))),
+ List[OrderElt](), None, None)
assert(expected === (a.parseAll(a.select, e).get))
}
@@ -132,13 +143,16 @@
FROM Employee AS R_emp
WHERE R_emp.manager=18 AND R_emp.lastName IS NOT NULL
"""
- val expected = Select(AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_emp")),
- Attribute(Name("lastName"))),
- AttrAlias(Name("A_empName"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None))),
- Some(ExprConjunction(Set(RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("manager")))),
- PrimaryExpressionTyped(Datatype.INTEGER,Name("18"))),
- RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("lastName")))))))))
+ val expected = Select(
+ false,
+ AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_emp")),
+ Attribute(Name("lastName"))),
+ AttrAlias(Name("A_empName"))))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None))),
+ Some(ExprConjunction(Set(RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("manager")))),
+ PrimaryExpressionTyped(Datatype.INTEGER,Name("18"))),
+ RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("lastName")))))))),
+ List[OrderElt](), None, None)
assert(expected === (a.parseAll(a.select, e).get))
}
@@ -150,16 +164,19 @@
INNER JOIN Employee AS R_manager
WHERE R_emp.manager=R_manager.id AND R_manager.lastName="Johnson" AND R_emp.lastName IS NOT NULL
"""
- val expected = Select(AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_emp")),
- Attribute(Name("lastName"))),
- AttrAlias(Name("A_empName"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None),
- InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_manager"))), None))),
- Some(ExprConjunction(Set(RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("manager")))),
- PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("id"))))),
- RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("lastName")))),
- PrimaryExpressionTyped(Datatype.STRING,Name("Johnson"))),
- RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("lastName")))))))))
+ val expected = Select(
+ false,
+ AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_emp")),
+ Attribute(Name("lastName"))),
+ AttrAlias(Name("A_empName"))))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None),
+ InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_manager"))), None))),
+ Some(ExprConjunction(Set(RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("manager")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("id"))))),
+ RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("lastName")))),
+ PrimaryExpressionTyped(Datatype.STRING,Name("Johnson"))),
+ RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("lastName")))))))),
+ List[OrderElt](), None, None)
assert(expected === (a.parseAll(a.select, e).get))
}
@@ -178,29 +195,32 @@
AND R_grandManager.birthday < R_manager.birthday
AND R_emp.lastName IS NOT NULL AND R_grandManager.lastName IS NOT NULL
"""
- val expected = Select(AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_emp")), Attribute(Name("lastName"))),
- AttrAlias(Name("A_empName"))),
- NamedAttribute(RelVarAttr(RelVar(Name("R_grandManager")),Attribute(Name("lastName"))),
- AttrAlias(Name("A_grandManagName"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None),
- InnerJoin(AliasedResource(Relation(Name("Manage")),RelVar(Name("R_lower"))), None),
- InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_manager"))), None),
- InnerJoin(AliasedResource(Relation(Name("Manage")),RelVar(Name("R_upper"))), None),
- InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_grandManager"))), None))),
- Some(ExprConjunction(Set(RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_lower")),Attribute(Name("manages")))),
- PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("id"))))),
- RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("id")))),
- PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_lower")),Attribute(Name("manager"))))),
- RelationalExpressionLt(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("birthday")))),
- PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("birthday"))))),
- RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_upper")),Attribute(Name("manages")))),
- PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("id"))))),
- RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_grandManager")),Attribute(Name("id")))),
- PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_upper")),Attribute(Name("manager"))))),
- RelationalExpressionLt(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_grandManager")),Attribute(Name("birthday")))),
- PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("birthday"))))),
- RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("lastName"))))),
- RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_grandManager")),Attribute(Name("lastName")))))))))
+ val expected = Select(
+ false,
+ AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_emp")), Attribute(Name("lastName"))),
+ AttrAlias(Name("A_empName"))),
+ NamedAttribute(RelVarAttr(RelVar(Name("R_grandManager")),Attribute(Name("lastName"))),
+ AttrAlias(Name("A_grandManagName"))))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None),
+ InnerJoin(AliasedResource(Relation(Name("Manage")),RelVar(Name("R_lower"))), None),
+ InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_manager"))), None),
+ InnerJoin(AliasedResource(Relation(Name("Manage")),RelVar(Name("R_upper"))), None),
+ InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_grandManager"))), None))),
+ Some(ExprConjunction(Set(RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_lower")),Attribute(Name("manages")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("id"))))),
+ RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("id")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_lower")),Attribute(Name("manager"))))),
+ RelationalExpressionLt(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("birthday")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("birthday"))))),
+ RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_upper")),Attribute(Name("manages")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("id"))))),
+ RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_grandManager")),Attribute(Name("id")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_upper")),Attribute(Name("manager"))))),
+ RelationalExpressionLt(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_grandManager")),Attribute(Name("birthday")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("birthday"))))),
+ RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("lastName"))))),
+ RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_grandManager")),Attribute(Name("lastName")))))))),
+ List[OrderElt](), None, None)
assert(expected === (a.parseAll(a.select, e).get))
}
@@ -222,37 +242,46 @@
) AS R_union1
WHERE R_union1.A_who=R_who.id AND R_who.lastName="Smith"
"""
- val expected = Select(AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_union1")), Attribute(Name("name"))),
- AttrAlias(Name("A_name"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_who"))), None),
- InnerJoin(AliasedResource(Subselect(Union(Set(
- Select(AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_manager")), Attribute(Name("lastName"))),
- AttrAlias(Name("A_name"))),
- NamedAttribute(RelVarAttr(RelVar(Name("R_above")), Attribute(Name("manages"))),
- AttrAlias(Name("A_who"))))),
- TableList(AddOrderedSet(
- InnerJoin(AliasedResource(Relation(Name("Manage")),RelVar(Name("R_above"))), None),
- InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_manager"))), None)
- )),
- Some(ExprConjunction(Set(RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_above")),Attribute(Name("manager")))),
- PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("id"))))),
- RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("lastName"))))))))),
- Select(AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_managed")), Attribute(Name("lastName"))),
- AttrAlias(Name("A_name"))),
- NamedAttribute(RelVarAttr(RelVar(Name("R_below")), Attribute(Name("manager"))),
- AttrAlias(Name("A_who"))))),
- TableList(AddOrderedSet(
- InnerJoin(AliasedResource(Relation(Name("Manage")),RelVar(Name("R_below"))), None),
- InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_managed"))), None)
- )),
- Some(ExprConjunction(Set(RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_below")),Attribute(Name("manages")))),
- PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_managed")),Attribute(Name("id"))))),
- RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_managed")),Attribute(Name("lastName")))))))))))),
+ val expected = Select(
+ false,
+ AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_union1")), Attribute(Name("name"))),
+ AttrAlias(Name("A_name"))))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_who"))), None),
+ InnerJoin(AliasedResource(Subselect(Union(Set(
+ Select(
+ false,
+ AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_manager")), Attribute(Name("lastName"))),
+ AttrAlias(Name("A_name"))),
+ NamedAttribute(RelVarAttr(RelVar(Name("R_above")), Attribute(Name("manages"))),
+ AttrAlias(Name("A_who"))))),
+ TableList(AddOrderedSet(
+ InnerJoin(AliasedResource(Relation(Name("Manage")),RelVar(Name("R_above"))), None),
+ InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_manager"))), None)
+ )),
+ Some(ExprConjunction(Set(RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_above")),Attribute(Name("manager")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("id"))))),
+ RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("lastName")))))))),
+ List[OrderElt](), None, None),
+ Select(
+ false,
+ AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_managed")), Attribute(Name("lastName"))),
+ AttrAlias(Name("A_name"))),
+ NamedAttribute(RelVarAttr(RelVar(Name("R_below")), Attribute(Name("manager"))),
+ AttrAlias(Name("A_who"))))),
+ TableList(AddOrderedSet(
+ InnerJoin(AliasedResource(Relation(Name("Manage")),RelVar(Name("R_below"))), None),
+ InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_managed"))), None)
+ )),
+ Some(ExprConjunction(Set(RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_below")),Attribute(Name("manages")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_managed")),Attribute(Name("id"))))),
+ RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_managed")),Attribute(Name("lastName")))))))),
+ List[OrderElt](), None, None)))),
RelVar(Name("R_union1"))), None))),
- Some(ExprConjunction(Set(RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_union1")),Attribute(Name("A_who")))),
- PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_who")),Attribute(Name("id"))))),
- RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_who")),Attribute(Name("lastName")))),
- PrimaryExpressionTyped(Datatype.STRING,Name("Smith")))))))
+ Some(ExprConjunction(Set(RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_union1")),Attribute(Name("A_who")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_who")),Attribute(Name("id"))))),
+ RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_who")),Attribute(Name("lastName")))),
+ PrimaryExpressionTyped(Datatype.STRING,Name("Smith")))))),
+ List[OrderElt](), None, None)
assert(expected === (a.parseAll(a.select, e).get))
}
@@ -263,14 +292,17 @@
FROM Manage AS R_above
WHERE R_above.id IS NOT NULL
"""
- val expected = Select(AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_above")),
- Attribute(Name("manages"))),
- AttrAlias(Name("A_who"))),
- NamedAttribute(ConstNULL(),
- AttrAlias(Name("A_bday"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Manage")),RelVar(Name("R_above"))), None))),
- Some(
- RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_above")),Attribute(Name("id")))))))
+ val expected = Select(
+ false,
+ AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_above")),
+ Attribute(Name("manages"))),
+ AttrAlias(Name("A_who"))),
+ NamedAttribute(ConstNULL(),
+ AttrAlias(Name("A_bday"))))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Manage")),RelVar(Name("R_above"))), None))),
+ Some(
+ RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_above")),Attribute(Name("id")))))),
+ List[OrderElt](), None, None)
assert(expected === (a.parseAll(a.select, e).get))
}
@@ -281,16 +313,17 @@
SELECT CONCAT(""" + QuotedBaseURI + """, "Employee", "/", "id", ".", R_emp.id, "#record") AS A_emp
FROM Employee AS R_emp
"""
- val expected = Select(AttributeList(Set(NamedAttribute(Concat(List(PrimaryExpressionTyped(Datatype("String"),Name("http://hr.example/DB/")),
- PrimaryExpressionTyped(Datatype("String"),Name("Employee")),
- PrimaryExpressionTyped(Datatype("String"),Name("/")),
- PrimaryExpressionTyped(Datatype("String"),Name("id")),
- PrimaryExpressionTyped(Datatype("String"),Name(".")),
- PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("id")))),
- PrimaryExpressionTyped(Datatype("String"),Name("#record")))),
- AttrAlias(Name("A_emp"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None))),
- None)
+ val expected = Select(
+ false, AttributeList(Set(NamedAttribute(Concat(List(PrimaryExpressionTyped(Datatype("String"),Name("http://hr.example/DB/")),
+ PrimaryExpressionTyped(Datatype("String"),Name("Employee")),
+ PrimaryExpressionTyped(Datatype("String"),Name("/")),
+ PrimaryExpressionTyped(Datatype("String"),Name("id")),
+ PrimaryExpressionTyped(Datatype("String"),Name(".")),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("id")))),
+ PrimaryExpressionTyped(Datatype("String"),Name("#record")))),
+ AttrAlias(Name("A_emp"))))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None))),
+ None, List[OrderElt](), None, None)
assert(expected === (a.parseAll(a.select, e).get))
}
@@ -301,21 +334,24 @@
FROM Manage AS R_above
WHERE (R_above.id IS NOT NULL) OR (R_above.id < 5 AND R_above.id < 3)
"""
- val expected = Select(AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_above")),
- Attribute(Name("manages"))),
- AttrAlias(Name("A_who"))),
- NamedAttribute(ConstNULL(),
- AttrAlias(Name("A_bday"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Manage")),RelVar(Name("R_above"))), None))),
- Some(
- ExprDisjunction(Set(
- RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_above")),Attribute(Name("id"))))),
- ExprConjunction(Set(
- RelationalExpressionLt(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_above")),Attribute(Name("id")))),
- PrimaryExpressionTyped(Datatype.INTEGER,Name("5"))),
- RelationalExpressionLt(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_above")),Attribute(Name("id")))),
- PrimaryExpressionTyped(Datatype.INTEGER,Name("3")))
- ))))))
+ val expected = Select(
+ false,
+ AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_above")),
+ Attribute(Name("manages"))),
+ AttrAlias(Name("A_who"))),
+ NamedAttribute(ConstNULL(),
+ AttrAlias(Name("A_bday"))))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Manage")),RelVar(Name("R_above"))), None))),
+ Some(
+ ExprDisjunction(Set(
+ RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_above")),Attribute(Name("id"))))),
+ ExprConjunction(Set(
+ RelationalExpressionLt(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_above")),Attribute(Name("id")))),
+ PrimaryExpressionTyped(Datatype.INTEGER,Name("5"))),
+ RelationalExpressionLt(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_above")),Attribute(Name("id")))),
+ PrimaryExpressionTyped(Datatype.INTEGER,Name("3")))
+ ))))),
+ List[OrderElt](), None, None)
assert(expected === (a.parseAll(a.select, e).get))
}
@@ -327,20 +363,23 @@
LEFT OUTER JOIN Manage AS R_mang ON R_mang.emp=R_emp.id
WHERE R_emp.lastName IS NOT NULL
"""
- val expected = Select(AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_emp")),
- Attribute(Name("lastName"))),
- AttrAlias(Name("A_empName"))),
- NamedAttribute(RelVarAttr(RelVar(Name("R_mang")),
- Attribute(Name("manageName"))),
- AttrAlias(Name("A_manageName"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None),
- LeftOuterJoin(AliasedResource(Relation(Name("Manage")),RelVar(Name("R_mang"))),
- RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_mang")),Attribute(Name("emp")))),
- PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("id"))))
- )))),
- Some(
- RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("lastName")))))
- ))
+ val expected = Select(
+ false,
+ AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_emp")),
+ Attribute(Name("lastName"))),
+ AttrAlias(Name("A_empName"))),
+ NamedAttribute(RelVarAttr(RelVar(Name("R_mang")),
+ Attribute(Name("manageName"))),
+ AttrAlias(Name("A_manageName"))))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None),
+ LeftOuterJoin(AliasedResource(Relation(Name("Manage")),RelVar(Name("R_mang"))),
+ RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_mang")),Attribute(Name("emp")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("id"))))
+ )))),
+ Some(
+ RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("lastName")))))
+ ),
+ List[OrderElt](), None, None)
assert(expected === (a.parseAll(a.select, e).get))
}
@@ -356,18 +395,23 @@
WHERE R_emp.lastName IS NOT NULL
"""
val expected =
- Select(AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("lastName"))),AttrAlias(Name("A_empName"))),
- NamedAttribute(RelVarAttr(RelVar(Name("R_mang")),Attribute(Name("manageName"))),AttrAlias(Name("A_manageName"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None),
- LeftOuterJoin(AliasedResource(
- Subselect(Select(AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("lastName"))),AttrAlias(Name("A_empName"))),
- NamedAttribute(RelVarAttr(RelVar(Name("R_mang")),Attribute(Name("manageName"))),AttrAlias(Name("A_manageName"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None))),
- None)),
- RelVar(Name("R_mang"))),
- RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_mang")),Attribute(Name("emp")))),
- PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("id")))))))),
- Some(RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("lastName")))))))
+ Select(
+ false,
+ AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("lastName"))),AttrAlias(Name("A_empName"))),
+ NamedAttribute(RelVarAttr(RelVar(Name("R_mang")),Attribute(Name("manageName"))),AttrAlias(Name("A_manageName"))))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None),
+ LeftOuterJoin(AliasedResource(
+ Subselect(Select(
+ false,
+ AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("lastName"))),AttrAlias(Name("A_empName"))),
+ NamedAttribute(RelVarAttr(RelVar(Name("R_mang")),Attribute(Name("manageName"))),AttrAlias(Name("A_manageName"))))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None))),
+ None, List[OrderElt](), None, None)),
+ RelVar(Name("R_mang"))),
+ RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_mang")),Attribute(Name("emp")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("id")))))))),
+ Some(RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("lastName")))))),
+ List[OrderElt](), None, None)
assert(expected === (a.parseAll(a.select, e).get))
}
@@ -496,22 +540,24 @@
R_emp.lastName AS O
FROM Employee AS R_emp
""" // "
- val expected = View(Relation(Name("triples")), Select(AttributeList(Set(
- NamedAttribute(Concat(List(PrimaryExpressionTyped(Datatype("String"),Name("http://hr.example/DB/")),
- PrimaryExpressionTyped(Datatype("String"),Name("Employee")),
- PrimaryExpressionTyped(Datatype("String"),Name("/")),
- PrimaryExpressionTyped(Datatype("String"),Name("empid")),
- PrimaryExpressionTyped(Datatype("String"),Name(".")),
- PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("id")))),
- PrimaryExpressionTyped(Datatype("String"),Name("#record")))),
- AttrAlias(Name("S"))),
- NamedAttribute(PrimaryExpressionTyped(Datatype.STRING,Name("<http://hr.example/DB/Employee#lastName>")),
- AttrAlias(Name("P"))),
- NamedAttribute(RelVarAttr(RelVar(Name("R_emp")),
- Attribute(Name("lastName"))),
- AttrAlias(Name("O"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None))),
- None))
+ val expected = View(Relation(Name("triples")), Select(
+ false,
+ AttributeList(Set(
+ NamedAttribute(Concat(List(PrimaryExpressionTyped(Datatype("String"),Name("http://hr.example/DB/")),
+ PrimaryExpressionTyped(Datatype("String"),Name("Employee")),
+ PrimaryExpressionTyped(Datatype("String"),Name("/")),
+ PrimaryExpressionTyped(Datatype("String"),Name("empid")),
+ PrimaryExpressionTyped(Datatype("String"),Name(".")),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("id")))),
+ PrimaryExpressionTyped(Datatype("String"),Name("#record")))),
+ AttrAlias(Name("S"))),
+ NamedAttribute(PrimaryExpressionTyped(Datatype.STRING,Name("<http://hr.example/DB/Employee#lastName>")),
+ AttrAlias(Name("P"))),
+ NamedAttribute(RelVarAttr(RelVar(Name("R_emp")),
+ Attribute(Name("lastName"))),
+ AttrAlias(Name("O"))))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None))),
+ None, List[OrderElt](), None, None))
assert(expected === (a.parseAll(a.createview, e).get))
}