Slick silently fails to save and doesn't' throw an exception

允我心安 提交于 2019-12-24 12:25:55

问题


I just ran into a very scary situation with slick. My table definition referred to a wrong column and I noticed that the inserts where not inserting yet there was no error/exception about the issue. It just "silently" failed.

Is this normal slick behaviour?

So my table definition was like:

  def expiredAt = column[Timestamp]["created_at"]
  def createdAt = column[Timestamp]["created_at"]

As you can see, the column referenced for both is the same column "created_at". When I changed the expiredAt column to "expired_at" everything worked fine.

But the really issue for me is that there was no exception thrown at all.

Is this normal slick behaviour? What is going on under the covers? Does it not return 0 for updatedRows?

My save method looks like:

(users returning users.map(_.id)) += user 

I am using slick3.


回答1:


Had the same problem, solved it with recover:

val query = (users returning earningsForms.map(_.id) += user
db.run(query).recover{ ex: Throwable => Logger.error("Error occured when inserting user", ex)}



回答2:


Don't know about Slick, but i've seen bonecp (default with play <2.4) swallow exceptions under certain conditions.

I had the same issue, wasted hours trying to find the problem. Stopped happening when I switched to HikariCP. Upgrade to play 2.4 if you can (uses hikaricp by default). If you're stuck on 2.3, you'll have to use the hikaricp play plugin.



来源:https://stackoverflow.com/questions/34579770/slick-silently-fails-to-save-and-doesnt-throw-an-exception

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!