SENTRY-392 fix a bug of CreateAsSelect and add test cases