Class ::xo::db::postgresql
::xo::db::postgresql
create ...
Defined in Class Relations
- class: ::xotcl::Class
![[i]](/resources/acs-subsite/ZoomIn16.gif)
- superclass: ::xo::db::SQL
![[i]](/resources/acs-subsite/ZoomIn16.gif)
- subclass: ::xo::db::DB-postgresql
, ::xo::db::DBI-postgresql![[i]](/resources/acs-subsite/ZoomIn16.gif)
::xotcl::Class create ::xo::db::postgresql \
-superclass ::xo::db::SQL
Methods (to be applied on instances)
<instance of xo::db::postgresql
> get_all_package_functions
- Testcases:
-
xotcl_core_tutorial_2, xotcl-core
set definitions [::xo::dc list_of_lists get_all_package_functions0 {
select
args.function,
args.arg_name,
args.arg_default
from acs_function_args args
order by function, arg_seq
}]
set last_function ""
set function_args {}
foreach definition $definitions {
lassign $definition function arg_name default
if {$last_function ne "" && $last_function ne $function} {
set ::xo::db::fnargs($last_function) $function_args
set function_args {}
}
lappend function_args [list $arg_name $default]
set last_function $function
}
set ::xo::db::fnargs($last_function) $function_args
ns_log notice "loaded [array size ::xo::db::fnargs] definitions from function args"
return [::xo::dc list_of_lists [self proc] {
select distinct
upper(substring(proname from 0 for position('__' in proname))) as package_name,
upper(substring(proname from position('__' in proname)+2)) as object_name
from pg_proc
where strpos(proname,'__') > 1
}] <instance of xo::db::postgresql
> map_datatype
- Testcases:
-
xotcl_core_tutorial_2, xotcl-core
switch -- $type {
string { set type text }
long_text { set type text }
date { set type "timestamp with timezone" }
ltree { set type [expr {[::xo::dc has_ltree] ? "ltree" : "text" }] }
default { return [next] }
}
return $type <instance of xo::db::postgresql
> nextval
- Testcases:
-
xotcl_core_tutorial_4, xotcl-core, test_cr_items
if {![info exists ::db::sequences]} {
ns_log notice "-- creating per thread sequence table"
foreach s [::xo::dc list relnames "select relname from pg_class where relkind = 'S'"] {
set ::db::sequences($s) 1
}
}
if {[info exists ::db::sequences(t_$sequence)]} {
set sequenceName t_$sequence
set nextval [::xo::dc get_value nextval "select nextval(:sequenceName)"]
} elseif {[info exists ::db::sequences($sequence)]} {
set sequenceName $sequence
set nextval [::xo::dc get_value nextval "select nextval(:sequenceName)"]
} elseif { [::xo::dc 0or1row nextval_sequence {
select nextval(:sequence) as nextval
where (select relkind
from pg_class
where relname = :sequence) = 'S'
}]} {
} else {
ns_log debug "db_nextval: sequence($sequence) is not a real sequence. Perhaps it uses the view hack."
set nextval [::xo::dc get_value nextval "select nextval from :sequence"]
}
return $nextval <instance of xo::db::postgresql
> select
- Testcases:
-
xotcl_core_tutorial_2, xotcl-core
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_clause $group_clause $order_clause $limit_clause $offset_clause"