Answer the question
In order to leave comments, you need to log in
Doctrine FunctionNode not found?
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
final class StringSimilarity extends FunctionNode {
...
public function parse(Parser $parser): void {
...
}
public function getSql(SqlWalker $sqlWalker): string {
return sprintf(
"SIMILARITY(LOWER(%s), LOWER(%s))",
$sqlWalker->walkStateFieldPathExpression($this->fieldName),
$sqlWalker->walkInParameter($this->similarStr)
);
}
}
SQLSTATE[HY000]: General error: 1 no such function: SIMILARITY. Code: 0 [] []
imports:
- { resource: '../parameters.xml' }
parameters:
# Adds a fallback DATABASE_URL if the env var is not set.
# This allows you to run cache:warmup even if your
# environment variables are not available yet.
# You should not need to set this value.
env(DATABASE_URL): ''
doctrine:
dbal:
driver: "%app.database_driver%"
dbname: "%app.database_name%"
host: "%app.database_host%"
port: "%app.database_port%"
user: "%app.database_user%"
password: "%app.database_password%"
charset: UTF8
default_table_options:
charset: UTF8
collate: utf8_unicode_ci
server_version: '13.0'
# unix_socket: /tmp/mysql.sock
orm:
auto_generate_proxy_classes: '%kernel.debug%'
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: false
second_level_cache:
enabled: true
mappings: # https://symfony.com/doc/current/reference/configuration/doctrine.html#mapping-configuration
App: # Kernel.php improves mappings
is_bundle: false
type: xml
dir: '%kernel.project_dir%/src/Infrastructure/Mapping/'
prefix: 'App\Domain'
alias: App
# Register new DQL functions
dql:
datetime_functions:
date_format: DoctrineExtensions\Query\Postgresql\DateFormat
at_time_zone: DoctrineExtensions\Query\Postgresql\AtTimeZoneFunction
string_functions:
similarity: App\Infrastructure\Persistence\FunctionsExtensions\StringSimilarity
imports:
- { resource: '../../parameters.xml' }
doctrine:
dbal:
default_connection: default
connections:
default:
driver: pdo_sqlite
path: '%kernel.cache_dir%/test.db'
memory: false
charset: UTF8
orm:
# Register new DQL functions
dql:
datetime_functions:
date_format: DoctrineExtensions\Query\Postgresql\DateFormat
at_time_zone: DoctrineExtensions\Query\Postgresql\AtTimeZoneFunction
string_functions:
similarity: App\Infrastructure\Persistence\FunctionsExtensions\StringSimilarity
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question