mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-12 06:56:24 +00:00
Adding sequence map to DboPostgres for database tables using non-standard sequences
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5110 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
7a380cc0de
commit
4ba97ca0da
1 changed files with 13 additions and 2 deletions
|
@ -71,7 +71,13 @@ class DboPostgres extends DboSource {
|
||||||
var $startQuote = '"';
|
var $startQuote = '"';
|
||||||
|
|
||||||
var $endQuote = '"';
|
var $endQuote = '"';
|
||||||
|
/**
|
||||||
|
* Contains mappings of custom auto-increment sequences, if a table uses a sequence name
|
||||||
|
* other than what is dictated by convention.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
var $_sequenceMap = array();
|
||||||
/**
|
/**
|
||||||
* Connects to the database using options in the given configuration array.
|
* Connects to the database using options in the given configuration array.
|
||||||
*
|
*
|
||||||
|
@ -152,6 +158,9 @@ class DboPostgres extends DboSource {
|
||||||
* @return array Fields in table. Keys are name and type
|
* @return array Fields in table. Keys are name and type
|
||||||
*/
|
*/
|
||||||
function &describe(&$model) {
|
function &describe(&$model) {
|
||||||
|
if (isset($model->sequence)) {
|
||||||
|
$this->_sequenceMap[$this->fullTableName($model, false)] = $model->sequence;
|
||||||
|
}
|
||||||
|
|
||||||
$cache = parent::describe($model);
|
$cache = parent::describe($model);
|
||||||
if ($cache != null) {
|
if ($cache != null) {
|
||||||
|
@ -345,7 +354,9 @@ class DboPostgres extends DboSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preg_match('/^nextval\(\'(\w+)\'/', $sourceinfo['default'], $matches)) {
|
if (isset($this->_sequenceMap[$source])) {
|
||||||
|
$seq = $this->_sequenceMap[$source];
|
||||||
|
} elseif (preg_match('/^nextval\(\'(\w+)\'/', $sourceinfo['default'], $matches)) {
|
||||||
$seq = $matches[1];
|
$seq = $matches[1];
|
||||||
} else {
|
} else {
|
||||||
$seq = "{$source}_{$field}_seq";
|
$seq = "{$source}_{$field}_seq";
|
||||||
|
|
Loading…
Add table
Reference in a new issue