--- parser3/src/classes/hash.C 2020/12/29 13:56:18 1.147 +++ parser3/src/classes/hash.C 2021/01/13 22:21:29 1.149 @@ -17,7 +17,7 @@ #include "pa_vbool.h" #include "pa_vmethod_frame.h" -volatile const char * IDENT_HASH_C="$Id: hash.C,v 1.147 2020/12/29 13:56:18 moko Exp $"; +volatile const char * IDENT_HASH_C="$Id: hash.C,v 1.149 2021/01/13 22:21:29 moko Exp $"; // class @@ -634,6 +634,7 @@ static void _select(Request& r, MethodPa int limit=source_hash.count(); bool reverse=false; + bool copy_default=false; if(params.count()>3) if(HashStringValue* options=params.as_hash(3)) { @@ -646,6 +647,10 @@ static void _select(Request& r, MethodPa valid_options++; reverse=r.process(*vreverse).as_bool(); } + if(Value* vcopy_default=options->get(sql_default_name)) { + valid_options++; + copy_default=r.process(*vcopy_default).as_bool(); + } if(valid_options!=options->count()) throw Exception(PARSER_RUNTIME, 0, CALLED_WITH_INVALID_OPTION); } @@ -686,11 +691,17 @@ static void _select(Request& r, MethodPa } } - r.write(*new VHash(result_hash)); + VHash *result=new VHash(result_hash); + if(copy_default){ + result->set_default(GET_SELF(r, VHashBase).get_default()); + } + + r.write(*result); } static void _reverse(Request& r, MethodParams& params) { - HashStringValue& source_hash=GET_SELF(r, VHashBase).hash(); + VHashBase& self=GET_SELF(r, VHashBase); + HashStringValue& source_hash=self.hash(); HashStringValue& result_hash=*new HashStringValue(); #ifdef HASH_ORDER @@ -700,7 +711,12 @@ static void _reverse(Request& r, MethodP for(HashStringValue::Iterator i(source_hash); i; i.next() ) result_hash.put(i.key(), i.value()); #endif - r.write(*new VHash(result_hash)); + + VHashBase& result=*new VHash(result_hash); + if(Value* vdefault=self.get_default()) + result.set_default(vdefault); + + r.write(result); } // constructor