package_object_view_helper (private)
package_object_view_helper [ -start_with start_with ] object_type
Defined in packages/acs-subsite/tcl/package-procs.tcl
Returns a select statement to be used as an inner view for selecting out all the attributes for the object_type.
- Switches:
- -start_with (optional, defaults to
"acs_object"
)- The highest parent object type for which to include attributes
- Parameters:
- object_type (required)
- The object for which to create a package spec
- Author:
- Michael Bryzek <mbryzek@arsdigita.com>
- Created:
- 10/2000
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: # Let's add the primary key for our lowest object type. We do this # separately in case there are no other attributes for this object type # Note that we also alias this primary key to object_id so # that the calling code can generically use it. acs_object_type::get -object_type $object_type -array acs_type set table_name $acs_type(table_name) set id_column $acs_type(id_column) set columns [list "${table_name}.${id_column}"] if { [string tolower $id_column] ne "object_id" } { # Add in an alias for object_id lappend columns "${table_name}.${id_column} as object_id" } set tables [list "${table_name}"] set primary_keys [list "${table_name}.${id_column}"] foreach row [package_object_attribute_list -start_with $start_with $object_type] { set table [lindex $row 1] set column [lindex $row 2] set object_column [lindex $row 8] if {[string tolower $column] eq "object_id"} { # We already have object_id... skip this column continue } # Do the column check first to include only the tables we need if {"$table.$column" in $columns} { # We already have a column with the same name. Keep the # first one as it's lower in the type hierarchy. continue } # first time we're seeing this column lappend columns "${table}.${column}" if {$table ni $tables} { # First time we're seeing this table lappend tables $table lappend primary_keys "${table}.${object_column}" } } set pk_formatted [list] for { set i 0 } { $i < [llength $primary_keys] - 1 } { incr i } { lappend pk_formatted "[lindex $primary_keys $i] = [lindex $primary_keys $i+1]" } set where_clause "" if {[llength $pk_formatted] > 0} { set where_clause [join [string tolower $pk_formatted] "\n AND "] set where_clause " WHERE $where_clause" } return "SELECT [string tolower [join $columns ",\n "]] FROM [string tolower [join $tables ", "]] $where_clause"Generic XQL file: packages/acs-subsite/tcl/package-procs.xql
PostgreSQL XQL file: packages/acs-subsite/tcl/package-procs-postgresql.xql
Oracle XQL file: packages/acs-subsite/tcl/package-procs-oracle.xql