Bugfix: when creating a paginator, queries containing $ variables cannot be passed by name and resolved by the
internal paginator machinery, because those vars won't be available in the expected evaluation scope when calling db_map.
Probably db_map could be made more clever about this, but as a simple solution for this case I have just made so the
pagination query is computed in the caller level and passed to the paginator directly.