Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/InsertSelectQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ public function build(DbFunctionsInterface|DbDriverInterface|null $dbDriverOrHel
throw new OrmInvalidFieldsException('You must specify the fields for insert');
}

$dbDriver = null;
$dbHelper = $dbDriverOrHelper;
if ($dbDriverOrHelper instanceof DbDriverInterface) {
$dbDriverOrHelper = $dbDriverOrHelper->getDbHelper();
$dbDriver = $dbDriverOrHelper;
$dbHelper = $dbDriverOrHelper->getDbHelper();
}

if (empty($this->query) && empty($this->sqlObject)) {
Expand All @@ -71,13 +74,13 @@ public function build(DbFunctionsInterface|DbDriverInterface|null $dbDriverOrHel
}

$fieldsStr = $this->fields;
if (!is_null($dbDriverOrHelper)) {
$fieldsStr = $dbDriverOrHelper->delimiterField($fieldsStr);
if (!is_null($dbHelper)) {
$fieldsStr = $dbHelper->delimiterField($fieldsStr);
}

$tableStr = $this->table;
if (!is_null($dbDriverOrHelper)) {
$tableStr = $dbDriverOrHelper->delimiterTable($tableStr);
if (!is_null($dbHelper)) {
$tableStr = $dbHelper->delimiterTable($tableStr);
}

$sql = 'INSERT INTO '
Expand All @@ -87,7 +90,7 @@ public function build(DbFunctionsInterface|DbDriverInterface|null $dbDriverOrHel
if (!is_null($this->sqlObject)) {
$fromObj = $this->sqlObject;
} else {
$fromObj = $this->query->build();
$fromObj = $this->query->build($dbDriver);
}

return new SqlObject($sql . $fromObj->getSql(), $fromObj->getParameters());
Expand Down
6 changes: 3 additions & 3 deletions src/Literal/HexUuidLiteral.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class HexUuidLiteral extends Literal

protected string $formattedUuid;

public function __construct(HexUuidLiteral|string $value)
public function __construct(Literal|string $value)
{
parent::__construct($this->binaryString($value));
}
Expand Down Expand Up @@ -39,7 +39,7 @@ public static function create(mixed $value): mixed
/**
* @throws InvalidArgumentException
*/
public function binaryString(HexUuidLiteral|string $value): string
public function binaryString(Literal|string $value): string
{
if ($value instanceof HexUuidLiteral) {
$value = $value->formattedUuid;
Expand All @@ -66,7 +66,7 @@ public static function getUuidFromLiteral(HexUuidLiteral $literal): string
/**
* @throws InvalidArgumentException
*/
public static function getFormattedUuid(HexUuidLiteral|string|null $item, bool $throwErrorIfInvalid = true, $default = null): ?string
public static function getFormattedUuid(Literal|string|null $item, bool $throwErrorIfInvalid = true, $default = null): ?string
{
if ($item instanceof Literal) {
$item = $item->__toString();
Expand Down
2 changes: 1 addition & 1 deletion src/Literal/MySqlUuidLiteral.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class MySqlUuidLiteral extends HexUuidLiteral
{
public function __construct(HexUuidLiteral|string $value)
public function __construct(Literal|string $value)
{
if ($value instanceof HexUuidLiteral) {
$value = $value->formattedUuid;
Expand Down
2 changes: 1 addition & 1 deletion src/Literal/PostgresUuidLiteral.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class PostgresUuidLiteral extends HexUuidLiteral
{
public function __construct(HexUuidLiteral|string $value)
public function __construct(Literal|string $value)
{
if ($value instanceof HexUuidLiteral) {
$value = $value->formattedUuid;
Expand Down
2 changes: 1 addition & 1 deletion src/Literal/SqlServerUuidLiteral.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class SqlServerUuidLiteral extends HexUuidLiteral
{
public function __construct(HexUuidLiteral|string $value)
public function __construct(Literal|string $value)
{
if ($value instanceof HexUuidLiteral) {
$value = $value->formattedUuid;
Expand Down
2 changes: 1 addition & 1 deletion src/Literal/SqliteUuidLiteral.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class SqliteUuidLiteral extends HexUuidLiteral
{
public function __construct(HexUuidLiteral|string $value)
public function __construct(Literal|string $value)
{
if ($value instanceof HexUuidLiteral) {
$value = $value->formattedUuid;
Expand Down
5 changes: 2 additions & 3 deletions src/UpdateQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function set(string $field, int|float|bool|string|LiteralInterface|null $
* Set a field with a literal value that will be used directly in the SQL query
*
* @param string $field
* @param string $value
* @param mixed $value
* @return $this
*/
public function setLiteral(string $field, mixed $value): UpdateQuery
Expand All @@ -70,11 +70,10 @@ public function setLiteral(string $field, mixed $value): UpdateQuery
protected function getJoinTables(DbFunctionsInterface|DbDriverInterface $dbDriverOrHelper = null): array
{
$dbDriver = null;
$dbHelper = $dbDriverOrHelper;
if ($dbDriverOrHelper instanceof DbDriverInterface) {
$dbDriver = $dbDriverOrHelper;
$dbHelper = $dbDriverOrHelper->getDbHelper();
} else {
$dbHelper = $dbDriverOrHelper;
}

if (is_null($dbHelper)) {
Expand Down