Ticket #761 (closed Feature Request: fixed)
Add Postgresql schema name support to ORM
| Reported by: | k4ml | Owned by: | Shadowhand |
|---|---|---|---|
| Priority: | minor | Milestone: | 2.2.1 |
| Component: | Libraries:ORM | Version: | SVN HEAD |
| Keywords: | postgresql schema | Cc: |
Description
Using model definition such as:
class Ap58a_Model extends ORM {
protected $object_name = 'ap58a';
protected $table_name = 'ap58a.ap58a';
protected $primary_key = 'ap58a_id';
protected $table_names_plural = False;
function get_last() {
return $this->db->get('ap58a.ap58a');
}
}
Would give an error message:-
The table property does not exist in the Ap58a_Model class.
Here the $table_name is defined as "schema_name"."table_name" as the existed in a different PostgreSQL schema other than the default "public".
The problem is in Pgsql::list_fields() method where the query used expect the plain table name without the schema prefix. The following patch fix this:-
public function list_fields($table, $query = FALSE)
{
static $tables;
if (strpos($table, '.')) {
list($schema_name, $table) = explode('.', $table);
}
// rest of the code
}
Change History
Note: See
TracTickets for help on using
tickets.
