As far as automatic tests for dbs - I have no idea what you are talking about unless you mean integration testing through a backend.
Automatic tests for a database could simply be writes followed by reads with expectations for the returned rows. This is how Postgres tests itself.
My personal go-to right now is ActiveRecord and RSpec. The examples could just as easily run raw SQL directly using the Ruby pg driver.
Since the application layer is much more naturally aligned with small well isolated chunks of logic it is easier to minimize the volume of code and logic in scope when testing a particular attribute - when that goes into the DB I've always seen things get more complex rapidly.
But this is not code, this SQL or equivalent, if SQL was known to be better than code to do busines logic everyone would do that.
What is your definition of code?
Plus, lots of those ORM things get plenty of hate from DBAs, I mean I like them but then again I'm not a very good programmer.
I am actually "good" at this stuff - writing logic in SQL through triggers, which call functions (at which SQL Server is way better than PG is) and stored procs, etc, and it's just a horrible, horrible practice.