part way on test: transform max joins
authorEric Prud'hommeaux <bertails@w3.org>
Tue, 15 Dec 2009 01:02:16 -0500
changeset 40 51d53d125401
parent 39 f75953a729c9
child 41 4eb3208b5ebe
part way on test: transform max joins
src/main/scala/RDB2RDFMain.scala
src/test/scala/RDB2RDFTest.scala
--- a/src/main/scala/RDB2RDFMain.scala	Mon Dec 14 21:13:55 2009 -0500
+++ b/src/main/scala/RDB2RDFMain.scala	Tue Dec 15 01:02:16 2009 -0500
@@ -240,11 +240,15 @@
 
     var notNulls:List[PrimaryExpressionNotNull] = List()
     r2rState.allVars.foreach(s => notNulls = nullGuard(notNulls, r2rState.inConstraint, r2rState.varmap, s))
+    val where = notNulls.size match {
+      case 0 => None
+      case _ => Some(Expression(notNulls))
+    }
 
     Select(
       AttributeList(attrlist),
       TableList(r2rState.joins),
-      Some(Expression(notNulls))
+      where
     )
   }
 }
--- a/src/test/scala/RDB2RDFTest.scala	Mon Dec 14 21:13:55 2009 -0500
+++ b/src/test/scala/RDB2RDFTest.scala	Tue Dec 15 01:02:16 2009 -0500
@@ -26,9 +26,9 @@
     val sqlSelect = sqlParser.parseAll(sqlParser.select, """
 SELECT R_emp.id AS A_emp
        FROM Employee AS R_emp
-            INNER JOIN Employee AS R_manager ON R_manager.id=R_emp.manager
-""").get
-    RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), PrimaryKey(Attribute(Name("id"))))
+            INNER JOIN Employee AS id18 ON id18.id=18
+""").get // !!! id18.id=R_emp.manager
+    assert(RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), PrimaryKey(Attribute(Name("id")))) === sqlSelect)
     true
   }