Fix deprecation warnings in internal SQLQuery usage
Merge pull request #3449 from camspiers/patch-2

Fix deprecation warnings in internal SQLQuery usage