fix to alloy deeper database references
cleaner impelementation based onf @FokkeZB's comment
Merge pull request #167 from dbankier/sql_sync_fix

fix to alloy deeper database references