After some playing around i think the problem is on my side:
select apm_package_version__version_name_greater('4.0.1', '4.0'); returns -1.
Could this be a problem with a wrong collation order or something like that ?