|
|
| version 1.40, 2025/05/27 15:10:24 | version 1.42, 2025/10/05 19:41:27 |
|---|---|
| Line 452 static void _sql(Request& r, MethodParam | Line 452 static void _sql(Request& r, MethodParam |
| Table2hash_value_type value_type=C_HASH; | Table2hash_value_type value_type=C_HASH; |
| if(params.count()>1) | if(params.count()>1) |
| if(HashStringValue* options=params.as_hash(1, "sql options")) { | if(HashStringValue* options=params.as_hash(1, "sql options")) { |
| int valid_options=0; | |
| bool distinct_specified=false; | bool distinct_specified=false; |
| for(HashStringValue::Iterator i(*options); i; i.next() ){ | for(HashStringValue::Iterator i(*options); i; i.next() ){ |
| String::Body key=i.key(); | String::Body key=i.key(); |
| Value* value=i.value(); | Value* value=i.value(); |
| if(key == sql_bind_name) { | if(key == sql_bind_name) { |
| bind=value->get_hash(); | bind=value->get_hash(); |
| valid_options++; | |
| } else if(key == sql_limit_name) { | } else if(key == sql_limit_name) { |
| limit=(ulong)r.process(*value).as_double(); | limit=(ulong)r.process(*value).as_double(); |
| valid_options++; | |
| } else if(key == sql_offset_name) { | } else if(key == sql_offset_name) { |
| offset=(ulong)r.process(*value).as_double(); | offset=(ulong)r.process(*value).as_double(); |
| valid_options++; | |
| } else if (key == sql_distinct_name) { | } else if (key == sql_distinct_name) { |
| distinct=r.process(*value).as_bool(); | distinct=r.process(*value).as_bool(); |
| distinct_specified=true; | distinct_specified=true; |
| valid_options++; | |
| } else if (key == sql_value_type_name) { | } else if (key == sql_value_type_name) { |
| value_type=get_value_type(r.process(*value)); | value_type=get_value_type(r.process(*value)); |
| valid_options++; | |
| } else if (key == "sparse") { | } else if (key == "sparse") { |
| sparse=r.process(*value).as_bool(); | sparse=r.process(*value).as_bool(); |
| valid_options++; | } else |
| } | throw Exception(PARSER_RUNTIME, 0, CALLED_WITH_INVALID_OPTION); |
| } | } |
| if(valid_options!=options->count()) | |
| throw Exception(PARSER_RUNTIME, 0, CALLED_WITH_INVALID_OPTION); | |
| if(distinct_specified && !sparse) | if(distinct_specified && !sparse) |
| throw Exception(PARSER_RUNTIME, 0, "'distinct' option can only be used when $.sparse(true) is specified"); | throw Exception(PARSER_RUNTIME, 0, "'distinct' option can only be used when $.sparse(true) is specified"); |
| } | } |
| Line 588 static void _keys(Request& r, MethodPara | Line 580 static void _keys(Request& r, MethodPara |
| for(ArrayValue::Iterator i(array); i; i.next()){ | for(ArrayValue::Iterator i(array); i; i.next()){ |
| if(i.value()){ | if(i.value()){ |
| Table::element_type row(new ArrayString(1)); | Table::element_type row(new ArrayString(1)); |
| *row+=new String(i.key(), String::L_TAINTED); | *row+=new String(pa_uitoa(i.index())); |
| *table+=row; | *table+=row; |
| } | } |
| } | } |