--- parser3/src/classes/table.C 2001/07/25 10:43:14 1.95 +++ parser3/src/classes/table.C 2001/07/28 12:07:26 1.97 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) */ -static const char *RCSId="$Id: table.C,v 1.95 2001/07/25 10:43:14 parser Exp $"; +static const char *RCSId="$Id: table.C,v 1.97 2001/07/28 12:07:26 parser Exp $"; #include "pa_config_includes.h" @@ -376,10 +376,11 @@ static void table_row_to_hash(Array::Ite } } static void _hash(Request& r, const String& method_name, MethodParams *params) { + Pool& pool=r.pool(); Table& table=static_cast(r.self)->table(); + Value& result=*new(pool) VHash(pool); if(const Array *columns=table.columns()) if(columns->size()>1) { - Pool& pool=r.pool(); const String& key_field_name=params->as_no_junction(0, "key field name must not be code").as_string(); @@ -402,12 +403,11 @@ static void _hash(Request& r, const Stri } // integers: key_field & value_fields - Value& result=*new(pool) VHash(pool); Row_info row_info={&table, key_field, &value_fields, result.get_hash()}; table.for_each(table_row_to_hash, &row_info); - result.set_name(method_name); - r.write_no_lang(result); } + result.set_name(method_name); + r.write_no_lang(result); } /// used by table: _sort / sort_cmp_string|sort_cmp_double @@ -648,14 +648,13 @@ static void _sql(Request& r, const Strin PTHROW(rethrow_me.type(), rethrow_me.code(), &statement_string, // setting more specific source [were url] rethrow_me.comment()); - - if(!handlers.table) - PTHROW(0, 0, - &statement_string, - "no table result"); + + Table *result= + handlers.table?handlers.table: // query resulted in table? return it + new(pool) Table(pool, &method_name, 0); // query returned no table, fake it // replace any previous table value - static_cast(r.self)->set_table(*handlers.table); + static_cast(r.self)->set_table(*result); } static void _dir(Request& r, const String& method_name, MethodParams *params) {