ahinz / geoslick Goto Github PK
View Code? Open in Web Editor NEWPostgis extension for Slick
License: BSD 3-Clause "New" or "Revised" License
Postgis extension for Slick
License: BSD 3-Clause "New" or "Revised" License
I've been trying to use geom.asGeoJson() in a query that gets turned into a prepared statement. The problem is that I get
ERROR: function st_asgeojson(bytea, integer) is not unique at character 31
HINT: Could not choose a best candidate function. You might need to add explicit type casts.
in my Postgres logs.
Here's what Postgres is trying to do:
STATEMENT: select x2."name", x2."state", ST_AsGeoJson(ST_AsEWKB(x2."geom"),1), x2."country", x3."email", x4."term", x5."career" from "term" x4, "career" x5, "cities" x2, "students" x3 where (((x4."term" = $1) and (x5."career" = $2)) and (x2."id" = $3)) and (((x3."city" = x2."id") and (x3."term" = x4."id")) and (x3."career" = x5."id"))
The query works wonderfully if it's not in a prepared statement.
Everything seems to be compiling properly, but if you will try to edit code which uses GeoSlick with IntelliJ then you will see a lot of red color ;) It is because of this fragment:
class SimpleQL extends super.SimpleQL with Implicits {
type Postgis = PostgisDriver.Postgis
type PostgisTable[T] = PostgisDriver.PostgisTable[T]
}
// (...)
override val simple = new SimpleQL
import simple._
I'm not sure if overriding val here is so good idea. It's quite similar to cake pattern, where def should be always preferred. If you would change this code to something like that:
class ExtendedQL extends super.SimpleQL with Implicits {
type Postgis = PostgisDriver.Postgis
type PostgisTable[T] = PostgisDriver.PostgisTable[T]
}
// (...)
val extended = new ExtendedQL
import extended._
and then fix few imports, then IntelliJ will be fixed.
And I think it will be also safer, since there will be no risk of some weird name collisions.
object Test extends Table[(String, Int, Int, Geometry, Array[Byte], Boolean)]("test") with
Postgis {
def key = column[String]("key", O.PrimaryKey)
def geom = geoColumn[Geometry]("geom", 0)
def * = key ~ geom
}
When trying to delete something:
val q = for (d <- Test if d.key === doc.key.toString) yield d
q.delete
I get:
scala.slick.SlickException: A query for a DELETE statement must resolve to a comprehension
with a single table -- Unsupported shape: Comprehension(fetch = None, offset = None)
at scala.slick.driver.BasicStatementBuilderComponent$QueryBuilder.buildDelete(BasicSt
atementBuilderComponent.scala:321)
at scala.slick.driver.BasicProfile$class.buildDeleteStatement(BasicProfile.scala:18)
at geoslick.PostgisDriver$.buildDeleteStatement(postgis.scala:275)
at scala.slick.driver.BasicInvokerComponent$DeleteInvoker.built$lzycompute(BasicInvok
erComponent.scala:50)
at scala.slick.driver.BasicInvokerComponent$DeleteInvoker.built(BasicInvokerComponent
.scala:50)
at scala.slick.driver.BasicInvokerComponent$DeleteInvoker.deleteStatement(BasicInvoke
rComponent.scala:52)
at scala.slick.driver.BasicInvokerComponent$DeleteInvoker.delete(BasicInvokerComponen
t.scala:54)
at Main$$anonfun$1.apply(Main.scala:40)
[..]
Could you make this available as in a maven/ivy/... repo somewhere?
I suggest having a look at how slick-joda-mapper gets deployed to sonatype oss
https://github.com/tototoshi/slick-joda-mapper
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.