Improved support for weirder custom SQL