note
when use following dependencies (i.e., use older version of anorm) below works expected (no exception thrown).
addsbtplugin("com.typesafe.play" % "sbt-plugin" % "2.3.8") "org.postgresql" % "postgresql" % "9.4-1202-jdbc42"
issue
in postgresql have user defined function
create or replace function ppersonget(p_personid bigint) returns table ( id bigint, shortname character varying, longname character varying, avatarurl character varying, isactive boolean) $$ begin return query select p.id, p.shortname, p.longname, p.avatarurl, p.isactive person p p_personid null or p.id = p_personid; end $$ language plpgsql;
when executing following find
function anorm 2.4
val selectstmt = """ select id, shortname, longname, avatarurl, isactive ppersonget({id}); """ .... .... val simple = { get[personid]("id") ~ str("shortname") ~ str("longname") ~ str("avatarurl") ~ get[boolean]("isactive") map { case id~shortname~longname~avatarurl~isactive => person(some(id), name(short, long), avatarurl, isactive) } } .... .... def find(id:option[personid]) : list[person] = { db.withconnection { implicit conn => anorm.sql(selectstmt).on("id" -> id).as(simple *) } }
i following exception
[psqlexception: multiple resultsets returned query.]
dependencies:
addsbtplugin("com.typesafe.play" % "sbt-plugin" % "2.4.0") "org.postgresql" % "postgresql" % "9.4-1202-jdbc42" "com.typesafe.play" %% "anorm" % "2.4.0"
scala version
scala-sdk-2.11.2
it's bug in jdbc driver, have here
when query string includes ";\n" in end of sql, query going fail error. bug found in versions 1202 , 1203. i'd recommend use version 9.4-1204+ or 9.3-1101.
p.s. answering here since page appears higher in google result
Comments
Post a Comment