[back-port of #1056]
Backport loopback-datasource-juggler#1022, loopback-datasource-juggler#1024, loopback-datasource-juggler#1026