-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from pfilsx/dev
Dev
- Loading branch information
Showing
34 changed files
with
500 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Pfilsx\PostgreSQLDoctrine\DBAL\Type; | ||
|
||
use Doctrine\DBAL\Platforms\AbstractPlatform; | ||
use Doctrine\DBAL\Types\Type; | ||
|
||
/** | ||
* Implementation of PostgreSql TSVECTOR data type. | ||
* | ||
* @see https://www.postgresql.org/docs/current/datatype-textsearch.html#DATATYPE-TSVECTOR | ||
*/ | ||
class TsVectorType extends Type | ||
{ | ||
/** | ||
* @param array<string, mixed> $column | ||
* @param AbstractPlatform $platform | ||
* | ||
* @return string | ||
*/ | ||
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string | ||
{ | ||
return 'TSVECTOR'; | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return 'tsvector'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Pfilsx\PostgreSQLDoctrine\ORM\Query\AST\Functions; | ||
|
||
use Doctrine\ORM\Query\AST\Functions\FunctionNode; | ||
use Doctrine\ORM\Query\AST\Node; | ||
use Doctrine\ORM\Query\Lexer; | ||
use Doctrine\ORM\Query\Parser; | ||
use Doctrine\ORM\Query\SqlWalker; | ||
|
||
abstract class AbstractToTsFunction extends FunctionNode | ||
{ | ||
private Node $document; | ||
|
||
private ?Node $config = null; | ||
|
||
abstract protected function getFunctionName(): string; | ||
|
||
public function parse(Parser $parser): void | ||
{ | ||
$parser->match(Lexer::T_IDENTIFIER); | ||
$parser->match(Lexer::T_OPEN_PARENTHESIS); | ||
|
||
$firstNode = $parser->StringPrimary(); | ||
|
||
$lexer = $parser->getLexer(); | ||
|
||
if ($lexer->isNextToken(Lexer::T_COMMA)) { | ||
$parser->match(Lexer::T_COMMA); | ||
$this->config = $firstNode; | ||
$this->document = $parser->StringPrimary(); | ||
} else { | ||
$this->document = $firstNode; | ||
} | ||
|
||
$parser->match(Lexer::T_CLOSE_PARENTHESIS); | ||
} | ||
|
||
public function getSql(SqlWalker $sqlWalker): string | ||
{ | ||
return sprintf('%s(%s%s)', | ||
$this->getFunctionName(), | ||
$this->config !== null ? $this->config->dispatch($sqlWalker) . ', ' : '', | ||
$this->document->dispatch($sqlWalker) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.