|
|
| version 1.12, 2024/09/28 21:28:57 | version 1.13, 2024/09/30 19:03:53 |
|---|---|
| Line 445 static void _sql(Request& r, MethodParam | Line 445 static void _sql(Request& r, MethodParam |
| 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; | int valid_options=0; |
| 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(); |
| Line 459 static void _sql(Request& r, MethodParam | Line 460 static void _sql(Request& r, MethodParam |
| valid_options++; | 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; | |
| valid_options++; | 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)); |
| Line 470 static void _sql(Request& r, MethodParam | Line 472 static void _sql(Request& r, MethodParam |
| } | } |
| if(valid_options!=options->count()) | if(valid_options!=options->count()) |
| throw Exception(PARSER_RUNTIME, 0, CALLED_WITH_INVALID_OPTION); | throw Exception(PARSER_RUNTIME, 0, CALLED_WITH_INVALID_OPTION); |
| if(distinct_specified && !sparse) | |
| throw Exception(PARSER_RUNTIME, 0, "'distinct' option can only be used when $.sparse(true) is specified"); | |
| } | } |
| SQL_Driver::Placeholder* placeholders=0; | SQL_Driver::Placeholder* placeholders=0; |
| Line 481 static void _sql(Request& r, MethodParam | Line 485 static void _sql(Request& r, MethodParam |
| const char* statement_cstr=statement_string.untaint_cstr(String::L_SQL, r.connection()); | const char* statement_cstr=statement_string.untaint_cstr(String::L_SQL, r.connection()); |
| VArray& self=GET_SELF(r, VArray); | VArray& self=GET_SELF(r, VArray); |
| self.array().clear(); self.invalidate(); // just in case if called as method | self.array().clear(); self.invalidate(); // just in case if called as method |
| if(sparse){ | if(sparse){ |