mirror of
https://github.com/yiisoft/yii2.git
synced 2026-02-20 00:32:19 +01:00
Fix #8298: Loading fixtures does not update table sequence for Postgresql database
This commit is contained in:
committed by
GitHub
parent
16f50626e1
commit
2e8f686b98
@@ -6,6 +6,7 @@ Yii Framework 2 Change Log
|
||||
|
||||
- Enh #20309: Add custom attributes support to style tags (nzwz)
|
||||
- Bug #20329: pgsql: Column Schema doesn't recognize PG type cast (arkhamvm)
|
||||
- Bug #8298: Loading fixtures does not update table sequence for Postgresql database (mtangoo)
|
||||
|
||||
|
||||
2.0.52 February 13, 2025
|
||||
|
||||
@@ -51,6 +51,10 @@ if you want to upgrade from version A to version C and there is
|
||||
version B between A and C, you need to follow the instructions
|
||||
for both A and B.
|
||||
|
||||
Upgrade from Yii 2.0.52
|
||||
-----------------------
|
||||
* There was a bug when loading fixtures into PostgreSQL database, the table sequences were not reset. If you used a work-around or if you depended on this behavior, you are advised to review your code.
|
||||
|
||||
Upgrade from Yii 2.0.51
|
||||
-----------------------
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @link https://www.yiiframework.com/
|
||||
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||
@@ -85,6 +86,9 @@ class ActiveFixture extends BaseActiveFixture
|
||||
$primaryKeys = $this->db->schema->insert($table->fullName, $row);
|
||||
$this->data[$alias] = array_merge($row, $primaryKeys);
|
||||
}
|
||||
if ($table->sequenceName !== null) {
|
||||
$this->db->createCommand()->executeResetSequence($table->fullName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @link https://www.yiiframework.com/
|
||||
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||
@@ -7,6 +8,8 @@
|
||||
|
||||
namespace yiiunit\framework\db\pgsql;
|
||||
|
||||
use yiiunit\framework\test\CustomerDbTestCase;
|
||||
|
||||
/**
|
||||
* @group db
|
||||
* @group pgsql
|
||||
@@ -15,4 +18,17 @@ namespace yiiunit\framework\db\pgsql;
|
||||
class ActiveFixtureTest extends \yiiunit\framework\test\ActiveFixtureTest
|
||||
{
|
||||
public $driverName = 'pgsql';
|
||||
|
||||
public function testFixturesLoadingResetsSeqence()
|
||||
{
|
||||
$test = new CustomerDbTestCase();
|
||||
$test->setUp();
|
||||
$fixture = $test->getFixture('customers');
|
||||
|
||||
$sequenceName = $fixture->getTableSchema()->sequenceName;
|
||||
$sequenceNextVal = $this->getConnection()->createCommand("SELECT currval('$sequenceName')")->queryScalar();
|
||||
$this->assertEquals($fixture->getModel('customer2')->id + 1, $sequenceNextVal);
|
||||
|
||||
$test->tearDown();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user