patch for build_query_spec