DEV: Use Rails query builder (PR #14759)

GitHub