~ update to use new ForeignKeyKey case class
authorEric Prud'hommeaux <eric@w3.org>
Mon, 31 Jan 2011 15:16:20 -0500
changeset 309 f839901e8183
parent 308 b7c8a3157e6c
child 310 a8ec8f49fb1b
~ update to use new ForeignKeyKey case class
sparql2sql/src/main/scala/SparqlToSql.scala
--- a/sparql2sql/src/main/scala/SparqlToSql.scala	Fri Jan 28 10:18:43 2011 -0500
+++ b/sparql2sql/src/main/scala/SparqlToSql.scala	Mon Jan 31 15:16:20 2011 -0500
@@ -292,10 +292,10 @@
       /** <pre>varConstraint(R_emp, Some(empid), VarAssignable(?emp), Employee) -&gt; RDFNoder(Employee,FullBinding(R_emp.empid))</pre> */
       case Some(rdb.RDB.CandidateKey(List(rdb.RDB.AttrName(constrainMe.attribute.n)))) => RDFNoder(rel, boundTo)
       case _ => {
-	val asKey = rdb.RDB.CandidateKey(List(constrainMe.attribute))
-	if (reldesc.fks.contains(asKey)) { // !! (0)
+	val asKey = List(constrainMe.attribute)
+	if (reldesc.fks.contains(rdb.RDB.CandidateKey(asKey))) { // !! (0)
 	  /** varConstraint(R_patient, Some(SexDE), VarAssignable(?_0_sexEntry), Person) -&gt; RDFNoder(Person,FullBinding(R_patient.SexDE)) */
-	  val rdb.RDB.Target(fkrel, fkattr) = reldesc.fks(asKey)
+	  val rdb.RDB.Target(fkrel, fkattr) = reldesc.fks(rdb.RDB.ForeignKeyKey(asKey))
 	  RDFNoder(rel, boundTo)
 	} else if (reldesc.header.contains(constrainMe.attribute)) {
 	  reldesc.header(constrainMe.attribute) match {
@@ -434,10 +434,10 @@
 	 * fkrel.fkattr (e.g. Employee.manager) may be a foreign key.
 	 * Calculate final relvarattr and relation.
 	 */
-	val asKey = rdb.RDB.CandidateKey(List(attr))
+	val asKey = List(attr)
 	val (targetattr:sql.RelVarAttr, targetrel, dt, state_fkeys:R2RState) =
-	  if (db(rel).fks.contains(asKey)) { // !! (0)
-	    val rdb.RDB.Target(fkrel, fkattr) = db(rel).fks(asKey)
+	  if (db(rel).fks.contains(rdb.RDB.CandidateKey(asKey))) { // !! (0)
+	    val rdb.RDB.Target(fkrel, fkattr) = db(rel).fks(rdb.RDB.ForeignKeyKey(asKey))
 	    try { db(fkrel).header(fkattr.attrs(0)) } catch { // !! (0)
 	      /** Foreign key relation.attribute was not found in the database description. */
 	      case e:java.util.NoSuchElementException =>
@@ -447,7 +447,7 @@
 	      if (db(fkrel).fks.contains(fkattr)) {
 	      /** Foreign key to something which is a foreign key. May have use
 	       * cases, but signal error until we figure out that they are. */
-		val rdb.RDB.Target(dfkrel, dfkattr) = db(fkrel).fks(fkattr)
+		val rdb.RDB.Target(dfkrel, dfkattr) = db(fkrel).fks(rdb.RDB.ForeignKeyKey(fkattr.attrs))
 		error("foreign key " + rel.n + "." + attr.n + 
 		      "->" + fkrel.n + "." + fkattr.attrs(0).n +  // !! (0)
 		      "->" + dfkrel.n + "." + dfkattr.attrs(0).n) // !! (0)