--- a/src/main/scala/SparqlToSql.scala Sat Feb 27 11:00:11 2010 -0500
+++ b/src/main/scala/SparqlToSql.scala Sat Feb 27 11:07:28 2010 -0500
@@ -13,6 +13,7 @@
import java.net.URI
import w3c.sw.sql
import w3c.sw.sql.PrettySql.toPrettySql
+import w3c.sw.rdf
import w3c.sw.sparql
import w3c.sw.util
@@ -367,11 +368,19 @@
case sparql.TermVar(v) => { // :sparql.Var
val l = varToAttribute(varmap, v)
val r = rTerm match {
- case sparql.TermUri(obj) => null // :sparql.Uri
+ case sparql.TermUri(u) => error("not implemented: translating RDF URI to SQL: " + u) // :sparql.Uri
case sparql.TermVar(v) => { // :sparql.Var
sql.PrimaryExpressionAttr(varToAttribute(varmap, v))
}
- case sparql.TermLit(lit) => null // :sparql.Literal => sql.PrimaryExpressionTyped(sql.Datatype, lit.n)
+ case sparql.TermLit(sparql.Literal(rdf.RDFLiteral(lit,rdf.Datatype(dt)))) =>
+ sql.PrimaryExpressionTyped({
+ dt.toString match {
+ case "http://www.w3.org/2001/XMLSchema#string" => sql.Datatype.STRING
+ case "http://www.w3.org/2001/XMLSchema#integer" => sql.Datatype.INTEGER
+ case "http://www.w3.org/2001/XMLSchema#date" => sql.Datatype.DATE
+ case _ => error("unable to translate to RDF literal SQL: \"" + lit + "\"^^<" + dt + ">")
+ }
+ }, lit)
}
sqlexpr(sql.PrimaryExpressionAttr(l), r)
}