apm_guess_db_type (public)

 apm_guess_db_type package_key path

Defined in packages/acs-bootstrap-installer/tcl/30-apm-load-procs.tcl

Guesses and returns the database type key corresponding to a particular path (or an empty string if none is known). $path should be relative to the package directory (e.g., www/index.tcl for /packages/bboard/admin-www/index.tcl). We consider two cases: 1. Data model files. If the path contains a string matching "sql/" followed by a database type known to this version of OpenACS, the file is assumed to be specific to that database type. The empty string is returned for all other data model files. Example: "sql/postgresql/apm-create.sql" is assumed to be the PostgreSQL-specific file used to create the APM datamodel. If the path contains a string matching "sql/common" the file is assumed to be compatible with all supported RDBMS's and a blank db_type is returned. Otherwise "oracle" is returned. This is a hardwired kludge to allow us to handle legacy ACS 4 packages. 2. Other files. If it is a .tcl, .xql, or .sqlj file not under the "sql" dir and whose name ends in a dash and database type, the file is assumed to be specific to that database type. Example: "tcl/10-database-postgresql-proc.tcl" is assumed to be the file that defines the PostgreSQL-specific portions of the database API.

Parameters:
package_key
path

Partial Call Graph (max 5 caller/called nodes):
%3 test_files__check_upgrade_ordering files__check_upgrade_ordering (test acs-tcl) apm_guess_db_type apm_guess_db_type test_files__check_upgrade_ordering->apm_guess_db_type ad_file ad_file (public) apm_guess_db_type->ad_file apm_guess_file_type apm_guess_file_type (public) apm_guess_db_type->apm_guess_file_type apm_data_model_scripts_find apm_data_model_scripts_find (public) apm_data_model_scripts_find->apm_guess_db_type apm_file_watchable_p apm_file_watchable_p (public) apm_file_watchable_p->apm_guess_db_type apm_get_package_files apm_get_package_files (public) apm_get_package_files->apm_guess_db_type apm_load_queries apm_load_queries (private) apm_load_queries->apm_guess_db_type packages/acs-admin/www/apm/version-files.tcl packages/acs-admin/ www/apm/version-files.tcl packages/acs-admin/www/apm/version-files.tcl->apm_guess_db_type

Testcases:
files__check_upgrade_ordering
Source code:
    set components [split $path "/"]
    set file_type [apm_guess_file_type $package_key $path]

    if { [string match "data_model*" $file_type] ||
         "ctl_file" eq $file_type } {
        set sql_index [lsearch $components "sql"]
        if { $sql_index >= 0 } {
            set db_dir [lindex $components $sql_index+1]
            if {$db_dir eq "common"} {
                return ""
            }
            foreach known_database_type $::acs::known_database_types {
                if {[lindex $known_database_type 0] eq $db_dir} {
                    return $db_dir
                }
            }
        }
        return "oracle"
    }
    
    set file_name [ad_file tail $path]
    foreach known_database_type $::acs::known_database_types {
        if { [regexp -- "\-[lindex $known_database_type 0]\.(xql|tcl|sqlj)\$" $file_name match] } {
            return [lindex $known_database_type 0]
        }
    }

    return ""
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: