mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-14 15:38:40 +00:00
fix
This commit is contained in:
parent
e78031906e
commit
a5ee11721f
|
|
@ -27,6 +27,14 @@ use phpOMS\DataStorage\Database\Query\QueryType;
|
||||||
*/
|
*/
|
||||||
abstract class BuilderAbstract
|
abstract class BuilderAbstract
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Log queries.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public static bool $log = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is read only.
|
* Is read only.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -43,14 +43,6 @@ class Builder extends BuilderAbstract
|
||||||
*/
|
*/
|
||||||
protected Grammar $grammar;
|
protected Grammar $grammar;
|
||||||
|
|
||||||
/**
|
|
||||||
* Log queries.
|
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
public static bool $log = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Columns.
|
* Columns.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -479,6 +479,12 @@ class Builder extends BuilderAbstract
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return \substr($queryString, 0, -1) . ';';
|
$query = \substr($queryString, 0, -1) . ';';
|
||||||
|
|
||||||
|
if (self::$log) {
|
||||||
|
\phpOMS\Log\FileLogger::getInstance()->debug($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
|
||||||
} elseif ($con instanceof SqlServerConnection) {
|
} elseif ($con instanceof SqlServerConnection) {
|
||||||
$sql = 'SELECT [table_name] FROM [sys].[tables] INNER JOIN [sys].[schemas] ON [sys].[tables.schema_id] = [sys].[schemas.schema_id];';
|
$sql = 'SELECT [table_name] FROM [sys].[tables] INNER JOIN [sys].[schemas] ON [sys].[tables.schema_id] = [sys].[schemas.schema_id];';
|
||||||
} elseif ($con instanceof SQLiteConnection) {
|
} elseif ($con instanceof SQLiteConnection) {
|
||||||
$sql = 'SELECT `name` FROM `sqlite_master` WHERE `type` = \'table\';';
|
$sql = 'SELECT `name` FROM `sqlite_master` WHERE `type` = ?;';
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = \strtr($sql, '[]', $iS . $iE);
|
$sql = \strtr($sql, '[]', $iS . $iE);
|
||||||
|
|
@ -139,7 +139,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
|
||||||
} elseif ($con instanceof SqlServerConnection) {
|
} elseif ($con instanceof SqlServerConnection) {
|
||||||
$sql = 'SELECT * FROM [information_schema].[columns] WHERE [table_schema] = ? AND [table_name] = ?;';
|
$sql = 'SELECT * FROM [information_schema].[columns] WHERE [table_schema] = ? AND [table_name] = ?;';
|
||||||
} elseif ($con instanceof SQLiteConnection) {
|
} elseif ($con instanceof SQLiteConnection) {
|
||||||
$sql = 'SELECT * FROM pragma_table_info(?) WHERE pragma_table_info(?) = ?;';
|
$sql = 'SELECT * FROM pragma_table_info(?) WHERE pragma_table_info(\'test\') = ?;';
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = \strtr($sql, '[]', $iS . $iE);
|
$sql = \strtr($sql, '[]', $iS . $iE);
|
||||||
|
|
@ -170,7 +170,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
|
||||||
} elseif ($con instanceof SqlServerConnection) {
|
} elseif ($con instanceof SqlServerConnection) {
|
||||||
$sql = 'CREATE TABLE IF NOT EXISTS [user_roles] ([user_id] INT AUTO_INCREMENT, [role_id] VARCHAR(10) DEFAULT ? NULL, PRIMARY KEY ([user_id]), FOREIGN KEY ([user_id]) REFERENCES [users] ([ext1_id]), FOREIGN KEY ([role_id]) REFERENCES [roles] ([ext2_id]));';
|
$sql = 'CREATE TABLE IF NOT EXISTS [user_roles] ([user_id] INT AUTO_INCREMENT, [role_id] VARCHAR(10) DEFAULT ? NULL, PRIMARY KEY ([user_id]), FOREIGN KEY ([user_id]) REFERENCES [users] ([ext1_id]), FOREIGN KEY ([role_id]) REFERENCES [roles] ([ext2_id]));';
|
||||||
} elseif ($con instanceof SQLiteConnection) {
|
} elseif ($con instanceof SQLiteConnection) {
|
||||||
$sql = 'CREATE TABLE [user_roles] ([user_id] INTEGER AUTOINCREMENT PRIMARY KEY, [role_id] TEXT DEFAULT ? NULL, FOREIGN KEY ([user_id]) REFERENCES [users] ([ext1_id]), FOREIGN KEY ([role_id]) REFERENCES [roles] ([ext2_id]));';
|
$sql = 'CREATE TABLE [user_roles] ([user_id] INTEGER PRIMARY KEY AUTOINCREMENT, [role_id] TEXT DEFAULT ? NULL, FOREIGN KEY ([user_id]) REFERENCES [users] ([ext1_id]), FOREIGN KEY ([role_id]) REFERENCES [roles] ([ext2_id]));';
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = \strtr($sql, '[]', $iS . $iE);
|
$sql = \strtr($sql, '[]', $iS . $iE);
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,8 @@ final class AddressTest extends \PHPUnit\Framework\TestCase
|
||||||
'state' => '',
|
'state' => '',
|
||||||
'lat' => 0.0,
|
'lat' => 0.0,
|
||||||
'lon' => 0.0,
|
'lon' => 0.0,
|
||||||
|
'id' => 0,
|
||||||
|
'type' => 1,
|
||||||
];
|
];
|
||||||
|
|
||||||
self::assertEquals('', $this->address->fao);
|
self::assertEquals('', $this->address->fao);
|
||||||
|
|
@ -77,6 +79,8 @@ final class AddressTest extends \PHPUnit\Framework\TestCase
|
||||||
'state' => '',
|
'state' => '',
|
||||||
'lat' => 0.0,
|
'lat' => 0.0,
|
||||||
'lon' => 0.0,
|
'lon' => 0.0,
|
||||||
|
'id' => 0,
|
||||||
|
'type' => 1,
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->address->fao = 'fao';
|
$this->address->fao = 'fao';
|
||||||
|
|
@ -98,6 +102,8 @@ final class AddressTest extends \PHPUnit\Framework\TestCase
|
||||||
'state' => '',
|
'state' => '',
|
||||||
'lat' => 0.0,
|
'lat' => 0.0,
|
||||||
'lon' => 0.0,
|
'lon' => 0.0,
|
||||||
|
'id' => 0,
|
||||||
|
'type' => 1,
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->address->fao = 'fao';
|
$this->address->fao = 'fao';
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ final class LocationTest extends \PHPUnit\Framework\TestCase
|
||||||
'lat' => 0.0,
|
'lat' => 0.0,
|
||||||
'lon' => 0.0,
|
'lon' => 0.0,
|
||||||
'id' => 0,
|
'id' => 0,
|
||||||
'type' => 2,
|
'type' => 1,
|
||||||
];
|
];
|
||||||
|
|
||||||
self::assertEquals('', $this->location->postal);
|
self::assertEquals('', $this->location->postal);
|
||||||
|
|
@ -163,6 +163,8 @@ final class LocationTest extends \PHPUnit\Framework\TestCase
|
||||||
public function testUnserialize() : void
|
public function testUnserialize() : void
|
||||||
{
|
{
|
||||||
$expected = [
|
$expected = [
|
||||||
|
'id' => 0,
|
||||||
|
'type' => 1,
|
||||||
'postal' => '0123456789',
|
'postal' => '0123456789',
|
||||||
'city' => 'city',
|
'city' => 'city',
|
||||||
'country' => 'Country',
|
'country' => 'Country',
|
||||||
|
|
@ -170,8 +172,6 @@ final class LocationTest extends \PHPUnit\Framework\TestCase
|
||||||
'state' => 'This is a state 123',
|
'state' => 'This is a state 123',
|
||||||
'lat' => 12.1,
|
'lat' => 12.1,
|
||||||
'lon' => 11.2,
|
'lon' => 11.2,
|
||||||
'id' => 0,
|
|
||||||
'type' => 2,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->location->unserialize(\json_encode($expected));
|
$this->location->unserialize(\json_encode($expected));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user