|
|
| version 1.151, 2021/11/04 21:31:15 | version 1.154, 2021/12/21 14:24:54 |
|---|---|
| Line 622 static void _at(Request& r, MethodParams | Line 622 static void _at(Request& r, MethodParams |
| extern String table_reverse_name; | extern String table_reverse_name; |
| static void _select(Request& r, MethodParams& params) { | static void _select(Request& r, MethodParams& params) { |
| InCycle temp(r); | |
| const String* key_var_name=¶ms.as_string(0, "key-var name must be string"); | const String* key_var_name=¶ms.as_string(0, "key-var name must be string"); |
| const String* value_var_name=¶ms.as_string(1, "value-var name must be string"); | const String* value_var_name=¶ms.as_string(1, "value-var name must be string"); |
| Value& vcondition=params.as_expression(2, "condition must be number, bool or expression"); | Value& vcondition=params.as_expression(2, "condition must be number, bool or expression"); |
| Line 658 static void _select(Request& r, MethodPa | Line 659 static void _select(Request& r, MethodPa |
| HashStringValue& result_hash=*new HashStringValue(); | HashStringValue& result_hash=*new HashStringValue(); |
| if(limit>0){ | if(limit>0){ |
| #ifdef HASH_ORDER | #ifdef HASH_ORDER |
| if(reverse){ | if(reverse){ |
| for(HashStringValue::ReverseIterator i(source_hash); i; i.prev()){ | for(HashStringValue::ReverseIterator i(source_hash); i; i.prev()){ |
| Line 666 static void _select(Request& r, MethodPa | Line 668 static void _select(Request& r, MethodPa |
| if(value_var_name) | if(value_var_name) |
| r.put_element(caller, *value_var_name, i.value()); | r.put_element(caller, *value_var_name, i.value()); |
| if(r.process(vcondition).as_bool()){ | bool condition=r.process(vcondition).as_bool(); |
| if(r.check_skip_break()) | |
| break; | |
| if(condition){ | |
| result_hash.put(i.key(), i.value()); | result_hash.put(i.key(), i.value()); |
| if(!--limit) | if(!--limit) |
| break; | break; |
| Line 682 static void _select(Request& r, MethodPa | Line 689 static void _select(Request& r, MethodPa |
| if(value_var_name) | if(value_var_name) |
| r.put_element(caller, *value_var_name, i.value()); | r.put_element(caller, *value_var_name, i.value()); |
| if(r.process(vcondition).as_bool()){ | bool condition=r.process(vcondition).as_bool(); |
| if(r.check_skip_break()) | |
| break; | |
| if(condition){ | |
| result_hash.put(i.key(), i.value()); | result_hash.put(i.key(), i.value()); |
| if(!--limit) | if(!--limit) |
| break; | break; |
| Line 728 static void _rename(Request& r, MethodPa | Line 740 static void _rename(Request& r, MethodPa |
| const String& key_to=params.as_string(1, "to key must be string"); | const String& key_to=params.as_string(1, "to key must be string"); |
| hash.rename(key_from, key_to); | hash.rename(key_from, key_to); |
| } else { | } else { |
| HashStringValue* names=params.as_hash(0); | HashStringValue* names=params.as_hash(0,"single parameter"); |
| for(HashStringValue::Iterator i(*names); i; i.next()) | for(HashStringValue::Iterator i(*names); i; i.next()) |
| hash.rename(i.key(), i.value()->as_string()); | hash.rename(i.key(), i.value()->as_string()); |