CREATE SEQUENCE account_id_seq;
CREATE TABLE account (
id integer NOT NULL PRIMARY KEY DEFAULT nextval('account_id_seq'),
email text NOT NULL,
password text NOT NULL,
name text NOT NULL
);
ALTER SEQUENCE account_id_seq OWNED BY account.id;
Here is my test that fails.
"The user class" should {
"be persisted" in {
implicit val context = inMemoryContext
running(FakeApplication()) {
User.create(User("emailaddress", "password", "Name"))
User.findAll must have size 1
}
}
}
and User.scala code:
/**
* Create a User.
*/
def create(user: User): User = {
DB.withConnection { implicit connection =>
SQL(
"""
insert into account values (
{email}, {password}, {name}
)
"""
).on(
'email -> user.email,
'password -> user.password,
'name -> user.name
).executeUpdate()
val id = SQL("SELECT SCOPE_IDENTITY()")().collect {
case Row(id: Int) => id
}.head
return User(user.email, user.password, user.name, new Id(id))
user
}
}
Im stumped as to why I am getting this error. Any ideas why I get this?
Todd
insert into account values (
{email}, {password}, {name}
)