migrate therinaldos.com data
Build & Deploy to DigitalOcean Space / build (push) Failing after 2m38s

This commit is contained in:
2024-05-05 15:50:45 -04:00
commit ef1ff240d4
23182 changed files with 3801898 additions and 0 deletions
@@ -0,0 +1,60 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
*
* @author Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\DB\Events;
/**
* Event to allow apps to register information about missing database columns
*
* This event will be dispatched for checking on the admin settings and when running
* occ db:add-missing-columns which will then create those columns
*
* @since 28.0.0
*/
class AddMissingColumnsEvent extends \OCP\EventDispatcher\Event {
/** @var array<array-key, array{tableName: string, columnName: string, typeName: string, options: array{}}> */
private array $missingColumns = [];
/**
* @param mixed[] $options
* @since 28.0.0
*/
public function addMissingColumn(string $tableName, string $columnName, string $typeName, array $options): void {
$this->missingColumns[] = [
'tableName' => $tableName,
'columnName' => $columnName,
'typeName' => $typeName,
'options' => $options,
];
}
/**
* @since 28.0.0
* @return array<array-key, array{tableName: string, columnName: string, typeName: string, options: array{}}>
*/
public function getMissingColumns(): array {
return $this->missingColumns;
}
}
@@ -0,0 +1,78 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
* @copyright Copyright (c) 2023 Julius Härtl <jus@bitgrid.net>
*
* @author Joas Schilling <coding@schilljs.com>
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\DB\Events;
/**
* Event to allow apps to register information about missing database indices
*
* This event will be dispatched for checking on the admin settings and when running
* occ db:add-missing-indices which will then create those indices
*
* @since 28.0.0
*/
class AddMissingIndicesEvent extends \OCP\EventDispatcher\Event {
/** @var array<array-key, array{tableName: string, indexName: string, columns: string[], options: array{}, dropUnnamedIndex: bool, uniqueIndex: bool}> */
private array $missingIndices = [];
/**
* @param string[] $columns
* @since 28.0.0
*/
public function addMissingIndex(string $tableName, string $indexName, array $columns, array $options = [], bool $dropUnnamedIndex = false): void {
$this->missingIndices[] = [
'tableName' => $tableName,
'indexName' => $indexName,
'columns' => $columns,
'options' => $options,
'dropUnnamedIndex' => $dropUnnamedIndex,
'uniqueIndex' => false,
];
}
/**
* @param string[] $columns
* @since 28.0.0
*/
public function addMissingUniqueIndex(string $tableName, string $indexName, array $columns, array $options = [], bool $dropUnnamedIndex = false): void {
$this->missingIndices[] = [
'tableName' => $tableName,
'indexName' => $indexName,
'columns' => $columns,
'options' => $options,
'dropUnnamedIndex' => $dropUnnamedIndex,
'uniqueIndex' => true,
];
}
/**
* @since 28.0.0
* @return array<array-key, array{tableName: string, indexName: string, columns: string[], options: array{}, dropUnnamedIndex: bool, uniqueIndex: bool}>
*/
public function getMissingIndices(): array {
return $this->missingIndices;
}
}
@@ -0,0 +1,60 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Julius Härtl <jus@bitgrid.net>
*
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\DB\Events;
/**
* Event to allow apps to register information about missing database primary keys
*
* This event will be dispatched for checking on the admin settings and when running
* occ db:add-missing-primary-keys which will then create those keys
*
* @since 28.0.0
*/
class AddMissingPrimaryKeyEvent extends \OCP\EventDispatcher\Event {
/** @var array<array-key, array{tableName: string, primaryKeyName: string, columns: string[], formerIndex: null|string}> */
private array $missingPrimaryKeys = [];
/**
* @param string[] $columns
* @since 28.0.0
*/
public function addMissingPrimaryKey(string $tableName, string $primaryKeyName, array $columns, ?string $formerIndex = null): void {
$this->missingPrimaryKeys[] = [
'tableName' => $tableName,
'primaryKeyName' => $primaryKeyName,
'columns' => $columns,
'formerIndex' => $formerIndex,
];
}
/**
* @since 28.0.0
* @return array<array-key, array{tableName: string, primaryKeyName: string, columns: string[], formerIndex: null|string}>
*/
public function getMissingPrimaryKeys(): array {
return $this->missingPrimaryKeys;
}
}
+148
View File
@@ -0,0 +1,148 @@
<?php
declare(strict_types=1);
/**
* @copyright 2021 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\DB;
use Exception as BaseException;
/**
* Database exception
*
* Thrown by Nextcloud's database abstraction layer. This is the base class that
* any specific exception will extend. Use this class in your try-catch to catch
* *any* error related to the database. Use any of the subclasses in the same
* namespace if you are only interested in specific errors.
*
* @psalm-immutable
* @since 21.0.0
*/
class Exception extends BaseException {
/**
* Nextcloud lost connection to the database
*
* @since 21.0.0
*/
public const REASON_CONNECTION_LOST = 1;
/**
* A database constraint was violated
*
* @since 21.0.0
*/
public const REASON_CONSTRAINT_VIOLATION = 2;
/**
* A database object (table, column, index) already exists
*
* @since 21.0.0
*/
public const REASON_DATABASE_OBJECT_EXISTS = 3;
/**
* A database object (table, column, index) can't be found
*
* @since 21.0.0
*/
public const REASON_DATABASE_OBJECT_NOT_FOUND = 4;
/**
* The database ran into a deadlock
*
* @since 21.0.0
*/
public const REASON_DEADLOCK = 5;
/**
* The database driver encountered an issue
*
* @since 21.0.0
*/
public const REASON_DRIVER = 6;
/**
* A foreign key constraint was violated
*
* @since 21.0.0
*/
public const REASON_FOREIGN_KEY_VIOLATION = 7;
/**
* An invalid argument was passed to the database abstraction
*
* @since 21.0.0
*/
public const REASON_INVALID_ARGUMENT = 8;
/**
* A field name was invalid
*
* @since 21.0.0
*/
public const REASON_INVALID_FIELD_NAME = 9;
/**
* A name in the query was ambiguous
*
* @since 21.0.0
*/
public const REASON_NON_UNIQUE_FIELD_NAME = 10;
/**
* A not null constraint was violated
*
* @since 21.0.0
*/
public const REASON_NOT_NULL_CONSTRAINT_VIOLATION = 11;
/**
* A generic server error was encountered
*
* @since 21.0.0
*/
public const REASON_SERVER = 12;
/**
* A syntax error was reported by the server
*
* @since 21.0.0
*/
public const REASON_SYNTAX_ERROR = 13;
/**
* A unique constraint was violated
*
* @since 21.0.0
*/
public const REASON_UNIQUE_CONSTRAINT_VIOLATION = 14;
/**
* @return int|null
* @psalm-return Exception::REASON_*
* @since 21.0.0
*/
public function getReason(): ?int {
return null;
}
}
@@ -0,0 +1,135 @@
<?php
declare(strict_types=1);
/**
* @copyright 2021 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\DB;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\ParameterType;
use PDO;
/**
* This interface allows you to prepare a database query.
*
* This interface must not be implemented in your application but
* instead obtained from IDBConnection::prepare.
*
* ```php
* $prepare = $this->db->prepare($query->getSql());
* ```
*
* @since 21.0.0
*/
interface IPreparedStatement {
/**
* @return true
*
* @since 21.0.0
* @deprecated 21.0.0 use \OCP\DB\IResult::closeCursor on the \OCP\DB\IResult returned by \OCP\IDBConnection::prepare
*/
public function closeCursor(): bool;
/**
* @param int $fetchMode
*
* @return mixed
*
* @since 21.0.0
* @deprecated 21.0.0 use \OCP\DB\IResult::fetch on the \OCP\DB\IResult returned by \OCP\IDBConnection::prepare
*/
public function fetch(int $fetchMode = PDO::FETCH_ASSOC);
/**
* @param int $fetchMode
*
* @return mixed[]
*
* @since 21.0.0
* @deprecated 21.0.0 use \OCP\DB\IResult::fetchAll on the \OCP\DB\IResult returned by \OCP\IDBConnection::prepare
*/
public function fetchAll(int $fetchMode = PDO::FETCH_ASSOC);
/**
* @return mixed
*
* @since 21.0.0
* @deprecated 21.0.0 use \OCP\DB\IResult::fetchColumn on the \OCP\DB\IResult returned by \OCP\IDBConnection::prepare
*/
public function fetchColumn();
/**
* @return mixed
*
* @since 21.0.0
* @deprecated 21.0.0 use \OCP\DB\IResult::fetchOne on the \OCP\DB\IResult returned by \OCP\IDBConnection::prepare
*/
public function fetchOne();
/**
* @param int|string $param
* @param mixed $value
* @param int $type
*
* @return bool
*
* @throws Exception
*
* @since 21.0.0
*/
public function bindValue($param, $value, $type = ParameterType::STRING): bool;
/**
* @param int|string $param
* @param mixed $variable
* @param int $type
* @param int|null $length
*
* @return bool
*
* @throws Exception
*
* @since 21.0.0
*/
public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null): bool;
/**
* @param mixed[]|null $params
*
* @return IResult
*
* @since 21.0.0
* @throws Exception
*/
public function execute($params = null): IResult;
/**
* @return int
*
* @since 21.0.0
*
* @throws Exception
* @deprecated 21.0.0 use \OCP\DB\IResult::rowCount on the \OCP\DB\IResult returned by \OCP\IDBConnection::prepare
*/
public function rowCount(): int;
}
+95
View File
@@ -0,0 +1,95 @@
<?php
declare(strict_types=1);
/**
* @copyright 2021 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\DB;
use PDO;
/**
* This interface represents the result of a database query.
*
* Usage:
*
* ```php
* $qb = $this->db->getQueryBuilder();
* $qb->select(...);
* $result = $query->executeQuery();
* ```
*
* This interface must not be implemented in your application.
*
* @since 21.0.0
*/
interface IResult {
/**
* @return true
*
* @since 21.0.0
*/
public function closeCursor(): bool;
/**
* @param int $fetchMode
*
* @return mixed
*
* @since 21.0.0
*/
public function fetch(int $fetchMode = PDO::FETCH_ASSOC);
/**
* @param int $fetchMode (one of PDO::FETCH_ASSOC, PDO::FETCH_NUM or PDO::FETCH_COLUMN (2, 3 or 7)
*
* @return mixed[]
*
* @since 21.0.0
*/
public function fetchAll(int $fetchMode = PDO::FETCH_ASSOC): array;
/**
* @return mixed
*
* @since 21.0.0
* @deprecated 21.0.0 use \OCP\DB\IResult::fetchOne
*/
public function fetchColumn();
/**
* Returns the first value of the next row of the result or FALSE if there are no more rows.
*
* @return false|mixed
*
* @since 21.0.0
*/
public function fetchOne();
/**
* @return int
*
* @since 21.0.0
*/
public function rowCount(): int;
}
@@ -0,0 +1,109 @@
<?php
/**
* @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com>
*
* @author Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\DB;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\AbstractPlatform;
/**
* This interface allows to get information about the database schema.
* This is particularly helpful for database migration scripts.
*
* This interface must not be implemented in your application but
* instead can be obtained in your migration scripts with the
* `$schemaClosure` Closure.
*
* @since 13.0.0
*/
interface ISchemaWrapper {
/**
* @param string $tableName
*
* @return \Doctrine\DBAL\Schema\Table
* @throws \Doctrine\DBAL\Schema\SchemaException
* @since 13.0.0
*/
public function getTable($tableName);
/**
* Does this schema have a table with the given name?
*
* @param string $tableName Prefix is automatically prepended
*
* @return boolean
* @since 13.0.0
*/
public function hasTable($tableName);
/**
* Creates a new table.
*
* @param string $tableName Prefix is automatically prepended
* @return \Doctrine\DBAL\Schema\Table
* @since 13.0.0
*/
public function createTable($tableName);
/**
* Drops a table from the schema.
*
* @param string $tableName Prefix is automatically prepended
* @return \Doctrine\DBAL\Schema\Schema
* @since 13.0.0
*/
public function dropTable($tableName);
/**
* Gets all tables of this schema.
*
* @return \Doctrine\DBAL\Schema\Table[]
* @since 13.0.0
*/
public function getTables();
/**
* Gets all table names, prefixed with table prefix
*
* @return array
* @since 13.0.0
*/
public function getTableNames();
/**
* Gets all table names
*
* @return array
* @since 13.0.0
*/
public function getTableNamesWithoutPrefix();
/**
* Gets the DatabasePlatform for the database.
*
* @return AbstractPlatform
*
* @throws Exception
* @since 23.0.0
*/
public function getDatabasePlatform();
}
@@ -0,0 +1,65 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Joas Schilling <coding@schilljs.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCP\DB\QueryBuilder;
/**
* This class provides a wrapper around Doctrine's CompositeExpression
* @since 8.2.0
*/
interface ICompositeExpression {
/**
* Adds multiple parts to composite expression.
*
* @param array $parts
*
* @return ICompositeExpression
* @since 8.2.0
*/
public function addMultiple(array $parts = []): ICompositeExpression;
/**
* Adds an expression to composite expression.
*
* @param mixed $part
*
* @return ICompositeExpression
* @since 8.2.0
*/
public function add($part): ICompositeExpression;
/**
* Retrieves the amount of expressions on composite expression.
*
* @return integer
* @since 8.2.0
*/
public function count(): int;
/**
* Returns the type of this composite expression (AND/OR).
*
* @return string
* @since 8.2.0
*/
public function getType(): string;
}
@@ -0,0 +1,444 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Daniel Kesselberg <mail@danielkesselberg.de>
* @author Joas Schilling <coding@schilljs.com>
* @author Lukas Reschke <lukas@statuscode.ch>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCP\DB\QueryBuilder;
use Doctrine\DBAL\Query\Expression\ExpressionBuilder;
/**
* This class provides a wrapper around Doctrine's ExpressionBuilder
* @since 8.2.0
*
* @psalm-taint-specialize
*/
interface IExpressionBuilder {
/**
* @since 9.0.0
*/
public const EQ = ExpressionBuilder::EQ;
/**
* @since 9.0.0
*/
public const NEQ = ExpressionBuilder::NEQ;
/**
* @since 9.0.0
*/
public const LT = ExpressionBuilder::LT;
/**
* @since 9.0.0
*/
public const LTE = ExpressionBuilder::LTE;
/**
* @since 9.0.0
*/
public const GT = ExpressionBuilder::GT;
/**
* @since 9.0.0
*/
public const GTE = ExpressionBuilder::GTE;
/**
* Creates a conjunction of the given boolean expressions.
*
* Example:
*
* [php]
* // (u.type = ?) AND (u.role = ?)
* $expr->andX('u.type = ?', 'u.role = ?'));
*
* @param mixed ...$x Optional clause. Defaults = null, but requires
* at least one defined when converting to string.
*
* @return \OCP\DB\QueryBuilder\ICompositeExpression
* @since 8.2.0
*
* @psalm-taint-sink sql $x
*/
public function andX(...$x): ICompositeExpression;
/**
* Creates a disjunction of the given boolean expressions.
*
* Example:
*
* [php]
* // (u.type = ?) OR (u.role = ?)
* $qb->where($qb->expr()->orX('u.type = ?', 'u.role = ?'));
*
* @param mixed ...$x Optional clause. Defaults = null, but requires
* at least one defined when converting to string.
*
* @return \OCP\DB\QueryBuilder\ICompositeExpression
* @since 8.2.0
*
* @psalm-taint-sink sql $x
*/
public function orX(...$x): ICompositeExpression;
/**
* Creates a comparison expression.
*
* @param mixed $x The left expression.
* @param string $operator One of the IExpressionBuilder::* constants.
* @param mixed $y The right expression.
* @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
* required when comparing text fields for oci compatibility
*
* @return string
* @since 8.2.0 - Parameter $type was added in 9.0.0
*
* @psalm-taint-sink sql $x
* @psalm-taint-sink sql $operator
* @psalm-taint-sink sql $y
* @psalm-taint-sink sql $type
*/
public function comparison($x, string $operator, $y, $type = null): string;
/**
* Creates an equality comparison expression with the given arguments.
*
* First argument is considered the left expression and the second is the right expression.
* When converted to string, it will generated a <left expr> = <right expr>. Example:
*
* [php]
* // u.id = ?
* $expr->eq('u.id', '?');
*
* @param mixed $x The left expression.
* @param mixed $y The right expression.
* @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
* required when comparing text fields for oci compatibility
*
* @return string
* @since 8.2.0 - Parameter $type was added in 9.0.0
*
* @psalm-taint-sink sql $x
* @psalm-taint-sink sql $y
* @psalm-taint-sink sql $type
*/
public function eq($x, $y, $type = null): string;
/**
* Creates a non equality comparison expression with the given arguments.
* First argument is considered the left expression and the second is the right expression.
* When converted to string, it will generated a <left expr> <> <right expr>. Example:
*
* [php]
* // u.id <> 1
* $q->where($q->expr()->neq('u.id', '1'));
*
* @param mixed $x The left expression.
* @param mixed $y The right expression.
* @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
* required when comparing text fields for oci compatibility
*
* @return string
* @since 8.2.0 - Parameter $type was added in 9.0.0
*
* @psalm-taint-sink sql $x
* @psalm-taint-sink sql $y
* @psalm-taint-sink sql $type
*/
public function neq($x, $y, $type = null): string;
/**
* Creates a lower-than comparison expression with the given arguments.
* First argument is considered the left expression and the second is the right expression.
* When converted to string, it will generated a <left expr> < <right expr>. Example:
*
* [php]
* // u.id < ?
* $q->where($q->expr()->lt('u.id', '?'));
*
* @param mixed $x The left expression.
* @param mixed $y The right expression.
* @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
* required when comparing text fields for oci compatibility
*
* @return string
* @since 8.2.0 - Parameter $type was added in 9.0.0
*
* @psalm-taint-sink sql $x
* @psalm-taint-sink sql $y
* @psalm-taint-sink sql $type
*/
public function lt($x, $y, $type = null): string;
/**
* Creates a lower-than-equal comparison expression with the given arguments.
* First argument is considered the left expression and the second is the right expression.
* When converted to string, it will generated a <left expr> <= <right expr>. Example:
*
* [php]
* // u.id <= ?
* $q->where($q->expr()->lte('u.id', '?'));
*
* @param mixed $x The left expression.
* @param mixed $y The right expression.
* @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
* required when comparing text fields for oci compatibility
*
* @return string
* @since 8.2.0 - Parameter $type was added in 9.0.0
*
* @psalm-taint-sink sql $x
* @psalm-taint-sink sql $y
* @psalm-taint-sink sql $type
*/
public function lte($x, $y, $type = null): string;
/**
* Creates a greater-than comparison expression with the given arguments.
* First argument is considered the left expression and the second is the right expression.
* When converted to string, it will generated a <left expr> > <right expr>. Example:
*
* [php]
* // u.id > ?
* $q->where($q->expr()->gt('u.id', '?'));
*
* @param mixed $x The left expression.
* @param mixed $y The right expression.
* @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
* required when comparing text fields for oci compatibility
*
* @return string
* @since 8.2.0 - Parameter $type was added in 9.0.0
*
* @psalm-taint-sink sql $x
* @psalm-taint-sink sql $y
* @psalm-taint-sink sql $type
*/
public function gt($x, $y, $type = null): string;
/**
* Creates a greater-than-equal comparison expression with the given arguments.
* First argument is considered the left expression and the second is the right expression.
* When converted to string, it will generated a <left expr> >= <right expr>. Example:
*
* [php]
* // u.id >= ?
* $q->where($q->expr()->gte('u.id', '?'));
*
* @param mixed $x The left expression.
* @param mixed $y The right expression.
* @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
* required when comparing text fields for oci compatibility
*
* @return string
* @since 8.2.0 - Parameter $type was added in 9.0.0
*
* @psalm-taint-sink sql $x
* @psalm-taint-sink sql $y
* @psalm-taint-sink sql $type
*/
public function gte($x, $y, $type = null): string;
/**
* Creates an IS NULL expression with the given arguments.
*
* @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be restricted by IS NULL.
*
* @return string
* @since 8.2.0
*
* @psalm-taint-sink sql $x
*/
public function isNull($x): string;
/**
* Creates an IS NOT NULL expression with the given arguments.
*
* @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be restricted by IS NOT NULL.
*
* @return string
* @since 8.2.0
*
* @psalm-taint-sink sql $x
*/
public function isNotNull($x): string;
/**
* Creates a LIKE() comparison expression with the given arguments.
*
* @param ILiteral|IParameter|IQueryFunction|string $x Field in string format to be inspected by LIKE() comparison.
* @param mixed $y Argument to be used in LIKE() comparison.
* @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
* required when comparing text fields for oci compatibility
*
* @return string
* @since 8.2.0 - Parameter $type was added in 9.0.0
*
* @psalm-taint-sink sql $x
* @psalm-taint-sink sql $y
* @psalm-taint-sink sql $type
*/
public function like($x, $y, $type = null): string;
/**
* Creates a NOT LIKE() comparison expression with the given arguments.
*
* @param ILiteral|IParameter|IQueryFunction|string $x Field in string format to be inspected by NOT LIKE() comparison.
* @param mixed $y Argument to be used in NOT LIKE() comparison.
* @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
* required when comparing text fields for oci compatibility
*
* @return string
* @since 8.2.0 - Parameter $type was added in 9.0.0
*
* @psalm-taint-sink sql $x
* @psalm-taint-sink sql $y
* @psalm-taint-sink sql $type
*/
public function notLike($x, $y, $type = null): string;
/**
* Creates a ILIKE() comparison expression with the given arguments.
*
* @param string $x Field in string format to be inspected by ILIKE() comparison.
* @param mixed $y Argument to be used in ILIKE() comparison.
* @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
* required when comparing text fields for oci compatibility
*
* @return string
* @since 9.0.0
*
* @psalm-taint-sink sql $x
* @psalm-taint-sink sql $y
* @psalm-taint-sink sql $type
*/
public function iLike($x, $y, $type = null): string;
/**
* Creates a IN () comparison expression with the given arguments.
*
* @param ILiteral|IParameter|IQueryFunction|string $x The field in string format to be inspected by IN() comparison.
* @param ILiteral|IParameter|IQueryFunction|string|array $y The placeholder or the array of values to be used by IN() comparison.
* @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
* required when comparing text fields for oci compatibility
*
* @return string
* @since 8.2.0 - Parameter $type was added in 9.0.0
*
* @psalm-taint-sink sql $x
* @psalm-taint-sink sql $y
* @psalm-taint-sink sql $type
*/
public function in($x, $y, $type = null): string;
/**
* Creates a NOT IN () comparison expression with the given arguments.
*
* @param ILiteral|IParameter|IQueryFunction|string $x The field in string format to be inspected by NOT IN() comparison.
* @param ILiteral|IParameter|IQueryFunction|string|array $y The placeholder or the array of values to be used by NOT IN() comparison.
* @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
* required when comparing text fields for oci compatibility
*
* @return string
* @since 8.2.0 - Parameter $type was added in 9.0.0
*
* @psalm-taint-sink sql $x
* @psalm-taint-sink sql $y
* @psalm-taint-sink sql $type
*/
public function notIn($x, $y, $type = null): string;
/**
* Creates a $x = '' statement, because Oracle needs a different check
*
* @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison.
* @return string
* @since 13.0.0
*
* @psalm-taint-sink sql $x
*/
public function emptyString($x): string;
/**
* Creates a `$x <> ''` statement, because Oracle needs a different check
*
* @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison.
* @return string
* @since 13.0.0
*
* @psalm-taint-sink sql $x
*/
public function nonEmptyString($x): string;
/**
* Creates a bitwise AND comparison
*
* @param string|ILiteral $x The field or value to check
* @param int $y Bitmap that must be set
* @return IQueryFunction
* @since 12.0.0
*
* @psalm-taint-sink sql $x
* @psalm-taint-sink sql $y
*/
public function bitwiseAnd($x, int $y): IQueryFunction;
/**
* Creates a bitwise OR comparison
*
* @param string|ILiteral $x The field or value to check
* @param int $y Bitmap that must be set
* @return IQueryFunction
* @since 12.0.0
*
* @psalm-taint-sink sql $x
* @psalm-taint-sink sql $y
*/
public function bitwiseOr($x, int $y): IQueryFunction;
/**
* Quotes a given input parameter.
*
* @param mixed $input The parameter to be quoted.
* @param int $type One of the IQueryBuilder::PARAM_* constants
*
* @return ILiteral
* @since 8.2.0
*
* @psalm-taint-sink sql $input
* @psalm-taint-sink sql $type
*/
public function literal($input, $type = IQueryBuilder::PARAM_STR): ILiteral;
/**
* Returns a IQueryFunction that casts the column to the given type
*
* @param string|IQueryFunction $column
* @param mixed $type One of IQueryBuilder::PARAM_*
* @psalm-param IQueryBuilder::PARAM_* $type
* @return IQueryFunction
* @since 9.0.0
*
* @psalm-taint-sink sql $column
* @psalm-taint-sink sql $type
*/
public function castColumn($column, $type): IQueryFunction;
}
@@ -0,0 +1,191 @@
<?php
/**
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
*
* @author Joas Schilling <coding@schilljs.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\DB\QueryBuilder;
/**
* This class provides a builder for sql some functions
*
* @since 12.0.0
*/
interface IFunctionBuilder {
/**
* Calculates the MD5 hash of a given input
*
* @param string|ILiteral|IParameter|IQueryFunction $input The input to be hashed
*
* @return IQueryFunction
* @since 12.0.0
*/
public function md5($input): IQueryFunction;
/**
* Combines two input strings
*
* @param string|ILiteral|IParameter|IQueryFunction $x Expressions or literal strings
* @param string|ILiteral|IParameter|IQueryFunction ...$exprs Expressions or literal strings
*
* @return IQueryFunction
* @since 12.0.0
*/
public function concat($x, ...$expr): IQueryFunction;
/**
* Returns a string which is the concatenation of all non-NULL values of X
*
* Usage examples:
*
* groupConcat('column') -- with comma as separator (default separator)
*
* groupConcat('column', ';') -- with different separator
*
* @param string|IQueryFunction $expr The expression to group
* @param string|null $separator The separator
* @return IQueryFunction
* @since 24.0.0
*/
public function groupConcat($expr, ?string $separator = ','): IQueryFunction;
/**
* Takes a substring from the input string
*
* @param string|ILiteral|IParameter|IQueryFunction $input The input string
* @param string|ILiteral|IParameter|IQueryFunction $start The start of the substring, note that counting starts at 1
* @param null|ILiteral|IParameter|IQueryFunction $length The length of the substring
*
* @return IQueryFunction
* @since 12.0.0
*/
public function substring($input, $start, $length = null): IQueryFunction;
/**
* Takes the sum of all rows in a column
*
* @param string|ILiteral|IParameter|IQueryFunction $field the column to sum
*
* @return IQueryFunction
* @since 12.0.0
*/
public function sum($field): IQueryFunction;
/**
* Transforms a string field or value to lower case
*
* @param string|ILiteral|IParameter|IQueryFunction $field
* @return IQueryFunction
* @since 14.0.0
*/
public function lower($field): IQueryFunction;
/**
* @param string|ILiteral|IParameter|IQueryFunction $x The first input field or number
* @param string|ILiteral|IParameter|IQueryFunction $y The second input field or number
* @return IQueryFunction
* @since 14.0.0
*/
public function add($x, $y): IQueryFunction;
/**
* @param string|ILiteral|IParameter|IQueryFunction $x The first input field or number
* @param string|ILiteral|IParameter|IQueryFunction $y The second input field or number
* @return IQueryFunction
* @since 14.0.0
*/
public function subtract($x, $y): IQueryFunction;
/**
* @param string|ILiteral|IParameter|IQueryFunction $count The input to be counted
* @param string $alias Alias for the counter
*
* @return IQueryFunction
* @since 14.0.0
*/
public function count($count = '', $alias = ''): IQueryFunction;
/**
* @param string|ILiteral|IParameter|IQueryFunction $field The input to be measured
* @param string $alias Alias for the length
*
* @return IQueryFunction
* @since 24.0.0
*/
public function octetLength($field, $alias = ''): IQueryFunction;
/**
* @param string|ILiteral|IParameter|IQueryFunction $field The input to be measured
* @param string $alias Alias for the length
*
* @return IQueryFunction
* @since 24.0.0
*/
public function charLength($field, $alias = ''): IQueryFunction;
/**
* Takes the maximum of all rows in a column
*
* If you want to get the maximum value of multiple columns in the same row, use `greatest` instead
*
* @param string|ILiteral|IParameter|IQueryFunction $field the column to maximum
*
* @return IQueryFunction
* @since 18.0.0
*/
public function max($field): IQueryFunction;
/**
* Takes the minimum of all rows in a column
*
* If you want to get the minimum value of multiple columns in the same row, use `least` instead
*
* @param string|ILiteral|IParameter|IQueryFunction $field the column to minimum
*
* @return IQueryFunction
* @since 18.0.0
*/
public function min($field): IQueryFunction;
/**
* Takes the maximum of multiple values
*
* If you want to get the maximum value of all rows in a column, use `max` instead
*
* @param string|ILiteral|IParameter|IQueryFunction $x
* @param string|ILiteral|IParameter|IQueryFunction $y
* @return IQueryFunction
* @since 18.0.0
*/
public function greatest($x, $y): IQueryFunction;
/**
* Takes the minimum of multiple values
*
* If you want to get the minimum value of all rows in a column, use `min` instead
*
* @param string|ILiteral|IParameter|IQueryFunction $x
* @param string|ILiteral|IParameter|IQueryFunction $y
* @return IQueryFunction
* @since 18.0.0
*/
public function least($x, $y): IQueryFunction;
}
@@ -0,0 +1,35 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Joas Schilling <coding@schilljs.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCP\DB\QueryBuilder;
/**
* @since 8.2.0
*/
interface ILiteral {
/**
* @return string
* @since 8.2.0
*/
public function __toString();
}
@@ -0,0 +1,35 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Joas Schilling <coding@schilljs.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCP\DB\QueryBuilder;
/**
* @since 8.2.0
*/
interface IParameter {
/**
* @return string
* @since 8.2.0
*/
public function __toString();
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,35 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Joas Schilling <coding@schilljs.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCP\DB\QueryBuilder;
/**
* @since 8.2.0
*/
interface IQueryFunction {
/**
* @return string
* @since 8.2.0
*/
public function __toString();
}
+119
View File
@@ -0,0 +1,119 @@
<?php
declare(strict_types=1);
/**
* @copyright 2021 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\DB;
/**
* Database types supported by Nextcloud's DBs
*
* Use these constants instead of \Doctrine\DBAL\Types\Type or \Doctrine\DBAL\Types\Types
*
* @since 21.0.0
*/
final class Types {
/**
* @var string
* @since 21.0.0
*/
public const BIGINT = 'bigint';
/**
* @var string
* @since 21.0.0
*/
public const BINARY = 'binary';
/**
* @var string
* @since 21.0.0
*/
public const BLOB = 'blob';
/**
* @var string
* @since 21.0.0
*/
public const BOOLEAN = 'boolean';
/**
* @var string
* @since 21.0.0
*/
public const DATE = 'date';
/**
* @var string
* @since 21.0.0
*/
public const DATETIME = 'datetime';
/**
* @var string
* @since 21.0.0
*/
public const DECIMAL = 'decimal';
/**
* @var string
* @since 21.0.0
*/
public const FLOAT = 'float';
/**
* @var string
* @since 21.0.0
*/
public const INTEGER = 'integer';
/**
* @var string
* @since 21.0.0
*/
public const SMALLINT = 'smallint';
/**
* @var string
* @since 21.0.0
*/
public const STRING = 'string';
/**
* @var string
* @since 21.0.0
*/
public const TEXT = 'text';
/**
* @var string
* @since 21.0.0
*/
public const TIME = 'time';
/**
* @var string
* @since 24.0.0
*/
public const JSON = 'json';
}