The clean & modern RSS server that doesn't give you any crap. https://thearsse.com/
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

42 lines
1.5 KiB

<?php
/** @license MIT
* Copyright 2017 J. King, Dustin Wilson et al.
* See LICENSE and AUTHORS files for details */
declare(strict_types=1);
namespace JKingWeb\Arsse\TestCase\Db\PosgreSQL;
/**
* @group excludeFromCoverage
* @covers \JKingWeb\Arsse\Database<extended>
* @covers \JKingWeb\Arsse\Misc\Query<extended>
*/
class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\Base {
protected static $implementation = "PDO PostgreSQL";
protected function nextID(string $table): int {
return (int) static::$drv->query("SELECT coalesce(last_value, (select max(id) from $table)) + 1 from pg_sequences where sequencename = '{$table}_id_seq'")->getValue();
}
public function setUp() {
parent::setUp();
$seqList =
"select
replace(substring(column_default, 10), right(column_default, 12), '') as seq,
table_name as table,
column_name as col
from information_schema.columns
where table_schema = current_schema()
and table_name like 'arsse_%'
and column_default like 'nextval(%'
";
foreach (static::$drv->query($seqList) as $r) {
$num = (int) static::$drv->query("SELECT max({$r['col']}) from {$r['table']}")->getValue();
if (!$num) {
continue;
}
$num++;
static::$drv->exec("ALTER SEQUENCE {$r['seq']} RESTART WITH $num");
}
}
}