mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-13 23:28:39 +00:00
add sqlsrv and fix system escaping
This commit is contained in:
parent
fd211cd949
commit
8fc34ef870
|
|
@ -48,7 +48,15 @@ abstract class GrammarAbstract
|
||||||
* @var string
|
* @var string
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected string $systemIdentifier = '"';
|
protected string $systemIdentifierStart = '"';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* System identifier.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected string $systemIdentifierEnd = '"';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* And operator.
|
* And operator.
|
||||||
|
|
@ -201,11 +209,13 @@ abstract class GrammarAbstract
|
||||||
*/
|
*/
|
||||||
protected function compileSystem(string $system) : string
|
protected function compileSystem(string $system) : string
|
||||||
{
|
{
|
||||||
$identifier = $this->systemIdentifier;
|
$identifierStart = $this->systemIdentifierStart;
|
||||||
|
$identifierEnd = $this->systemIdentifierEnd;
|
||||||
|
|
||||||
foreach ($this->specialKeywords as $keyword) {
|
foreach ($this->specialKeywords as $keyword) {
|
||||||
if (\strrpos($system, $keyword, -\strlen($system)) !== false) {
|
if (\strrpos($system, $keyword, -\strlen($system)) !== false) {
|
||||||
$identifier = '';
|
$identifierStart = '';
|
||||||
|
$identifierEnd = '';
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -216,9 +226,9 @@ abstract class GrammarAbstract
|
||||||
|
|
||||||
foreach ($split as $key => $system) {
|
foreach ($split as $key => $system) {
|
||||||
$fullSystem .= '.'
|
$fullSystem .= '.'
|
||||||
. ($system !== '*' ? $identifier : '')
|
. ($system !== '*' ? $identifierStart : '')
|
||||||
. $system
|
. $system
|
||||||
. ($system !== '*' ? $identifier : '');
|
. ($system !== '*' ? $identifierEnd : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
return \ltrim($fullSystem, '.');
|
return \ltrim($fullSystem, '.');
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,15 @@ class MysqlGrammar extends Grammar
|
||||||
* @var string
|
* @var string
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected string $systemIdentifier = '`';
|
protected string $systemIdentifierStart = '`';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* System identifier.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected string $systemIdentifierEnd = '`';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compile random.
|
* Compile random.
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,15 @@ class SQLiteGrammar extends Grammar
|
||||||
* @var string
|
* @var string
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public string $systemIdentifier = '`';
|
public string $systemIdentifierStart = '`';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* System identifier.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected string $systemIdentifierEnd = '`';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compile random.
|
* Compile random.
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,22 @@ use phpOMS\DataStorage\Database\Query\Builder;
|
||||||
*/
|
*/
|
||||||
class SqlServerGrammar extends Grammar
|
class SqlServerGrammar extends Grammar
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* System identifier.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected string $systemIdentifierStart = '[';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* System identifier.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected string $systemIdentifierEnd = ']';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compile random.
|
* Compile random.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,15 @@ class MysqlGrammar extends Grammar
|
||||||
* @var string
|
* @var string
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected string $systemIdentifier = '`';
|
protected string $systemIdentifierStart = '`';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* System identifier.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected string $systemIdentifierEnd = '`';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compile remove
|
* Compile remove
|
||||||
|
|
|
||||||
|
|
@ -30,5 +30,13 @@ class SQLiteGrammar extends Grammar
|
||||||
* @var string
|
* @var string
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected string $systemIdentifier = '`';
|
protected string $systemIdentifierStart = '`';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* System identifier.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected string $systemIdentifierEnd = '`';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,4 +24,19 @@ namespace phpOMS\DataStorage\Database\Schema\Grammar;
|
||||||
*/
|
*/
|
||||||
class SqlServerGrammar extends Grammar
|
class SqlServerGrammar extends Grammar
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* System identifier.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected string $systemIdentifierStart = '[';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* System identifier.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected string $systemIdentifierEnd = ']';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ class MysqlGrammarTest extends \PHPUnit\Framework\TestCase
|
||||||
public function testDefault() : void
|
public function testDefault() : void
|
||||||
{
|
{
|
||||||
self::assertInstanceOf('\phpOMS\DataStorage\Database\Query\Grammar\Grammar', new MysqlGrammar());
|
self::assertInstanceOf('\phpOMS\DataStorage\Database\Query\Grammar\Grammar', new MysqlGrammar());
|
||||||
self::assertEquals('`', TestUtils::getMember(new MysqlGrammar(), 'systemIdentifier'));
|
self::assertEquals('`', TestUtils::getMember(new MysqlGrammar(), 'systemIdentifierStart'));
|
||||||
|
self::assertEquals('`', TestUtils::getMember(new MysqlGrammar(), 'systemIdentifierEnd'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ class SQLiteGrammarTest extends \PHPUnit\Framework\TestCase
|
||||||
public function testDefault() : void
|
public function testDefault() : void
|
||||||
{
|
{
|
||||||
self::assertInstanceOf('\phpOMS\DataStorage\Database\Query\Grammar\Grammar', new SqliteGrammar());
|
self::assertInstanceOf('\phpOMS\DataStorage\Database\Query\Grammar\Grammar', new SqliteGrammar());
|
||||||
self::assertEquals('`', TestUtils::getMember(new SqliteGrammar(), 'systemIdentifier'));
|
self::assertEquals('`', TestUtils::getMember(new SqliteGrammar(), 'systemIdentifierStart'));
|
||||||
|
self::assertEquals('`', TestUtils::getMember(new SqliteGrammar(), 'systemIdentifierEnd'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,8 @@ class MysqlGrammarTest extends \PHPUnit\Framework\TestCase
|
||||||
public function testDefault() : void
|
public function testDefault() : void
|
||||||
{
|
{
|
||||||
self::assertInstanceOf('\phpOMS\DataStorage\Database\Schema\Grammar\Grammar', new MysqlGrammar());
|
self::assertInstanceOf('\phpOMS\DataStorage\Database\Schema\Grammar\Grammar', new MysqlGrammar());
|
||||||
self::assertEquals('`', TestUtils::getMember(new MysqlGrammar(), 'systemIdentifier'));
|
self::assertEquals('`', TestUtils::getMember(new MysqlGrammar(), 'systemIdentifierStart'));
|
||||||
|
self::assertEquals('`', TestUtils::getMember(new MysqlGrammar(), 'systemIdentifierEnd'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ class SQLiteGrammarTest extends \PHPUnit\Framework\TestCase
|
||||||
public function testDefault() : void
|
public function testDefault() : void
|
||||||
{
|
{
|
||||||
self::assertInstanceOf('\phpOMS\DataStorage\Database\Schema\Grammar\Grammar', new SQLiteGrammar());
|
self::assertInstanceOf('\phpOMS\DataStorage\Database\Schema\Grammar\Grammar', new SQLiteGrammar());
|
||||||
self::assertEquals('`', TestUtils::getMember(new SQLiteGrammar(), 'systemIdentifier'));
|
self::assertEquals('`', TestUtils::getMember(new SQLiteGrammar(), 'systemIdentifierStart'));
|
||||||
|
self::assertEquals('`', TestUtils::getMember(new SQLiteGrammar(), 'systemIdentifierEnd'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user