Fix deprecation warnings in internal SQLQuery usage