Testing with more reasonable deps interface

Would like to have an object method returning the implied dependencies,
stuff the object knows from other fields (`get_implied_deps()`), and one
returning all the dependencies, including the unexpected stuff found in
pg_depend from the db and in depends_on from yaml (`get_deps()`). So on
topo-sort we would use `get_deps()` and when saving we would save
`get_deps()` - `get_implied_deps()`.

I have some problem now seeing what code paths receive a db and what
should live whitout, so I'm stashing these changes for now.
Pass the db around explicitly when getting the dependencies

This allows to implement a single function where each object
can return the database object it knows it depends on. The same
function is used both when getting the dependencies to walk the
objects graph and when storing the yaml to avoid saving redundant
information.

A `db` parameter has been added to `_base_map()` and all the
`to_map()` methods.
Provide some stability to the objects ordering in sql

First emit the non-schema object, then the schema ones, trying to group
them by type and alphabetically, but of course the order dependency
wins.