sql scope adjustments for postgres compat