Fix NULL and NOT_NULL conditions in 'scan'