fix invalid NOT usage in as_sql