xo::db::Class instproc check_table_atts (public)
<instance of xo::db::Class> check_table_atts
Defined in /var/www/openacs.org/packages/xotcl-core/tcl/05-db-procs.tcl
Check table_name and id_column and set meaningful defaults, if these attributes are not provided.
Source code: :check_default_values set table_name_error_tail "" set id_column_error_tail "" if {![info exists :sql_package_name]} { set :sql_package_name [self] #:log "-- sql_package_name of [self] is '${:sql_package_name}'" } if {[string length ${:sql_package_name}] > 30} { error "SQL package_name '${:sql_package_name}' can be maximal 30 characters long! Please specify a shorter sql_package_name in the class definition." } if {${:sql_package_name} eq ""} { error "Cannot determine SQL package_name. Please specify it explicitly!" } if {![info exists :table_name]} { set tail [namespace tail [self]] regexp {^::([^:]+)::} [self] _ head :table_name [string tolower ${head}_$tail] #:log "-- table_name of [self] is '[:table_name]'" set table_name_error_tail ", or use different namespaces/class names" } if {![info exists :id_column]} { set :id_column [string tolower [namespace tail [self]]]_id set id_column_error_tail ", or use different class names" #:log "-- created id_column '[:id_column]'" } if {![regexp {^[[:alpha:]_][[:alnum:]_]*$} [:table_name]]} { error "Table name '[:table_name]' is unsafe in SQL: Please specify a different table_name$table_name_error_tail." } if {[string length [:table_name]] > 30} { error "SQL table_name '[:table_name]' can be maximal 30 characters long! Please specify a shorter table_name in the class definition." } if {![regexp {^[[:alpha:]_][[:alnum:]_]*$} [:id_column]]} { error "Name for id_column '[:id_column]' is unsafe in SQL: Please specify a different id_column$id_column_error_tail" }XQL Not present: Generic, PostgreSQL, Oracle