Fixed #22738 -- made finer distinctions for when Boolean is not detected on Oracle

This is first served as a PR for two purposes:

1) To let interested parties review it
2) To verify by Jenkins that the fix indeed works.
Better make it a method instead of a lambda. If I'm not mistaken lambda expression assignment is also a flake8 violation.