--- parser3/src/classes/table.C 2008/05/14 10:19:04 1.242 +++ parser3/src/classes/table.C 2008/06/26 15:00:42 1.244 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_TABLE_C="$Date: 2008/05/14 10:19:04 $"; +static const char * const IDENT_TABLE_C="$Date: 2008/06/26 15:00:42 $"; #ifndef NO_STRINGSTREAM #include @@ -666,15 +666,13 @@ static void table_row_to_hash(Table::ele if(!key) return; // ignore rows without key [too-short-record_array if-indexed] - bool exist = false; - switch (info->value_type) { - case C_STRING: - { + bool exist=false; + switch(info->value_type) { + case C_STRING: { exist=info->hash->put_dont_replace(*key, new VString(*row->get(info->value_fields->get(0)))); + break; } - break; - case C_HASH: - { + case C_HASH: { VHash* vhash=new VHash; HashStringValue& hash=vhash->hash(); for(Array_iterator i(*info->value_fields); i.has_next(); ) { @@ -686,18 +684,16 @@ static void table_row_to_hash(Table::ele } exist=info->hash->put_dont_replace(*key, vhash); + break; } - break; - case C_TABLE: - { - VTable* vtable=(VTable*)info->hash->get(*key); // put. table existed? - if( info->distinct==D_ILLEGAL ){ - exist=true; - break; - } - + case C_TABLE: { + VTable* vtable=(VTable*)info->hash->get(*key); // table exist? Table* table; if(vtable) { + if(info->distinct==D_ILLEGAL) { + exist=true; + break; + } table=vtable->get_table(); } else { // no? creating table of same structure as source @@ -706,8 +702,8 @@ static void table_row_to_hash(Table::ele info->hash->put(*key, new VTable(table)); } *table+=row; + break; } - break; } if(exist && info->distinct==D_ILLEGAL) throw Exception(PARSER_RUNTIME, @@ -1121,7 +1117,7 @@ static void _sql(Request& r, MethodParam Value& statement=params.as_junction(0, "statement must be code"); HashStringValue* bind=0; - ulong limit=0; + ulong limit=SQL_NO_LIMIT; ulong offset=0; if(params.count()>1) { Value& voptions=params.as_no_junction(1, "options must be hash, not code"); @@ -1133,8 +1129,13 @@ static void _sql(Request& r, MethodParam bind=vbind->get_hash(); } if(Value* vlimit=options->get(sql_limit_name)) { - valid_options++; - limit=(ulong)r.process_to_value(*vlimit).as_double(); + if(vlimit->is_defined()){ + valid_options++; + limit=(ulong)r.process_to_value(*vlimit).as_double(); + } else + throw Exception(PARSER_RUNTIME, + 0, + "limit must be defined"); } if(Value* voffset=options->get(sql_offset_name)) { valid_options++;