For some reason the JDBC postgres driver is adding: RETURNING * to the
end off certain select statements.
Does anyone have any idea why?
I think it has something to do with (Anorm.scala):
798 def getFilledStatement(connection:java.sql.Connection) = {
799 val s
=connection.prepareStatement(sql.query,java.sql.Statement.RETURN_GENERATED_KEYS)
PSQLException occured : ERROR: syntax error at or near "RETURNING"
package controllers
import play._
import play.mvc._
import play.db.anorm._
import models._
import templates.Template
object Application extends Controller {
def index = Template
def listNodes = {
val node = Node.find("id={id}").on("id" -> 3).first()
Text(node)
}
}
package models
import play.db.anorm._
import play.db.anorm.defaults._
case class Node(
node_id: Pk[Int],
node_type: Int,
template_id: Int
)
object Node extends Magic[Node](Some("nodes"))
Table "public.nodes"
Column | Type |
Modifiers
--------------+--------------------------
+-----------------------------------------------------------
node_id | integer | not null default
nextval(('node_id_seq'::text)::regclass)
node_type_id | integer | not null
template_id | integer | not null
timestamp | timestamp with time zone | default
('now'::text)::timestamp(6) with time zone
Indexes:
"nodes_pkey" PRIMARY KEY, btree (node_id)
"n_node_id_index" btree (node_id)
"n_node_type_id_index" btree (node_type_id)
"n_template_id_index" btree (template_id)
Execution exception (In /app/controllers.scala around line 14)
PSQLException occured : ERROR: syntax error at or near "RETURNING"
Position: 33
play.exceptions.JavaExecutionException: ERROR: syntax error at or near
"RETURNING"
Position: 33
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:227)
at Invocation.HTTP Request(Play!)
Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at
or near "RETURNING"
Position: 33
at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:
2102)
at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:
1835)
at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:
257)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:
500)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:
388)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:
273)
at play.db.anorm.Sql$class.resultSet(Anorm.scala:844)
at play.db.anorm.SimpleSql.resultSet(Anorm.scala:784)
at play.db.anorm.Sql$class.parse(Anorm.scala:850)
at play.db.anorm.SimpleSql.parse(Anorm.scala:784)
at play.db.anorm.SimpleSql.first(Anorm.scala:796)
at controllers.Application$.listNodes(app/controllers.scala:14)
at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:
540)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:498)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:
492)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:
469)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:157)
Node.find("node_id={node_id}").on("node_id" -> 3)().toList
--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
def create(user: User): User = {
DB.withConnection { implicit connection =>
val id: Long = SQL(
"""
insert into account (email, password, name) values (
{email}, {password}, {name}
"""
).on(
'email -> user.email,
'password -> user.password,
'name -> user.name
).executeInsert().get
User(user.email, user.password, user.name, new Id(id.toInt))