--- parser3/src/classes/table.C 2016/07/29 13:30:42 1.315 +++ parser3/src/classes/table.C 2016/07/29 22:40:58 1.317 @@ -22,7 +22,7 @@ #define USE_STRINGSTREAM #endif -volatile const char * IDENT_TABLE_C="$Id: table.C,v 1.315 2016/07/29 13:30:42 moko Exp $"; +volatile const char * IDENT_TABLE_C="$Id: table.C,v 1.317 2016/07/29 22:40:58 moko Exp $"; // class @@ -705,11 +705,10 @@ static void _menu(Request& r, MethodPara Table& table=GET_SELF(r, VTable).table(); size_t saved_current=table.current(); - size_t size=table.count(); if(delim_maybe_code) { // delimiter set bool need_delim=false; - for(size_t row=0; rowvalue_type) { case C_STRING: { - size_t index=info->value_fields->get(0); - exist=info->hash->put_dont_replace(*key, (index < row->count()) ? new VString(*row->get(index)) : new VString()); + if(info->value_fields->count()){ + size_t index=info->value_fields->get(0); + exist=info->hash->put_dont_replace(*key, (index < row->count()) ? new VString(*row->get(index)) : VString::empty()); + } else { + exist=info->hash->put_dont_replace(*key, VString::empty()); + } break; } case C_HASH: { @@ -899,10 +902,12 @@ static void _hash(Request& r, MethodPara throw Exception(PARSER_RUNTIME, 0, "you can't specify value field(s) with option $.distinct[tables] or $.type[tables]"); Value& value_fields_param=params[1]; - if(value_fields_param.get_junction()){ + if(value_fields_param.get_junction()){ // code specified value_code=&value_fields_param; } else if(value_fields_param.is_string()) { // one column as string was specified - value_fields+=self_table.column_name2index(*value_fields_param.get_string(), true); + const String &field_name=*value_fields_param.get_string(); + if(!field_name.is_empty()) + value_fields+=self_table.column_name2index(field_name, true); } else if(Table* value_fields_table=value_fields_param.get_table()) { // list of columns were specified in table for(Array_iterator i(*value_fields_table); i.has_next(); ) { const String& value_field_name =*i.next()->get(0); @@ -1083,7 +1088,6 @@ static void _foreach(Request& r, MethodP Table& table=GET_SELF(r, VTable).table(); size_t saved_current=table.current(); - size_t size=table.count(); const String* rownum_var_name=rownum_name.is_empty()? 0 : &rownum_name; const String* value_var_name=value_name.is_empty()? 0 : &value_name; @@ -1092,7 +1096,7 @@ static void _foreach(Request& r, MethodP if(delim_maybe_code) { // delimiter set bool need_delim=false; - for(size_t row=0; row