Index: openacs-4/packages/xotcl-core/tcl/05-db-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/05-db-procs.tcl,v diff -u -r1.2.2.3 -r1.2.2.4 --- openacs-4/packages/xotcl-core/tcl/05-db-procs.tcl 12 Sep 2007 11:31:16 -0000 1.2.2.3 +++ openacs-4/packages/xotcl-core/tcl/05-db-procs.tcl 2 Nov 2007 11:11:56 -0000 1.2.2.4 @@ -112,19 +112,20 @@ sql proc select { -vars:required -from:required - -where:required + {-where ""} {-groupby ""} {-limit ""} {-offset ""} {-start ""} {-orderby ""} {-map_function_names false} } { + set where_clause [expr {$where ne "" ? "WHERE $where" : ""}] set offset_clause [expr {$offset ne "" ? "OFFSET $offset" : ""}] set limit_clause [expr {$limit ne "" ? "LIMIT $limit" : ""}] set order_clause [expr {$orderby ne "" ? "ORDER BY $orderby" : ""}] set group_clause [expr {$groupby ne "" ? "GROUP BY $groupby" : ""}] - return "SELECT $vars FROM $from WHERE $where $group_clause $order_clause $limit_clause $offset_clause" + return "SELECT $vars FROM $from $where_clause $group_clause $order_clause $limit_clause $offset_clause" } sql proc date_trunc {field date} { @@ -163,7 +164,7 @@ sql proc select { -vars:required -from:required - -where:required + {-where ""} {-groupby ""} {-limit ""} {-offset ""} @@ -172,10 +173,11 @@ {-map_function_names false} } { # "-start" not used so far + set where_clause [expr {$where ne "" ? "WHERE $where" : ""}] set order_clause [expr {$orderby ne "" ? "ORDER BY $orderby" : ""}] set group_clause [expr {$groupby ne "" ? "GROUP BY $groupby" : ""}] if {$map_function_names} {set vars [::xo::db::function_name $vars]} - set sql "SELECT $vars FROM $from WHERE $where $group_clause" + set sql "SELECT $vars FROM $from $where_clause $group_clause" if {$limit ne "" || $offset ne ""} { if {$offset eq ""} { set limit_clause "ROWNUM <= $limit"