mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-20 17:15:51 +02:00
Use postgres native array_position function instead of our FIELD function and pass it as array literal instead of variadic function
Otherwise we will run into errors, that we can not give more than 100 arguments to a function
This commit is contained in:
parent
8bb8118d9f
commit
0a482da93e
4 changed files with 90 additions and 17 deletions
|
@ -202,15 +202,6 @@ final class Version20240606203053 extends AbstractMultiPlatformMigration impleme
|
|||
$this->addSql('ALTER TABLE "users" ADD CONSTRAINT FK_1483A5E938248176 FOREIGN KEY (currency_id) REFERENCES currencies (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE webauthn_keys ADD CONSTRAINT FK_799FD143A76ED395 FOREIGN KEY (user_id) REFERENCES "users" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
|
||||
//Create the FIELD() function for PostgreSQL
|
||||
$this->addSql(<<<SQL
|
||||
CREATE OR REPLACE FUNCTION FIELD(anyelement, VARIADIC anyarray) RETURNS bigint AS $$
|
||||
SELECT n FROM (
|
||||
SELECT row_number() OVER () AS n, x FROM unnest($2) x)
|
||||
numbered WHERE numbered.x = $1;
|
||||
$$ LANGUAGE SQL IMMUTABLE STRICT;
|
||||
SQL);
|
||||
|
||||
//Create the initial groups and users
|
||||
//Retrieve the json representations of the presets
|
||||
$admin = $this->getJSONPermDataFromPreset(PermissionPresetsHelper::PRESET_ADMIN);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue