简体   繁体   English

Symfony 4.4/Doctrine PostgreSQL 查询 IS NOT TRUE

[英]Symfony 4.4/Doctrine PostgreSQL query with IS NOT TRUE

I am having an issue with the Doctrine Query Builder in my Symfony 4.4 application.我的 Symfony 4.4 应用程序中的 Doctrine 查询生成器出现问题。

The specific part of my query that is failing is the IS NOT TRUE part.我的查询失败的特定部分是IS NOT TRUE部分。

I get the following error:我收到以下错误:

In QueryException.php line 32:
                                                                                     
  [Syntax Error] line 0, col 829: Error: Expected =, <, <=, <>, >, >=, !=, got 'IS'  
$qb = $this->_em->createQueryBuilder();
$qb->select(
   $qb->expr()->count('s.id').' AS total_clubs',
   "SUM(CASE WHEN s.currentTier = 'platinum' AND s.uefa IS NOT TRUE THEN 1 ELSE 0 END) AS platinum_clubs_non_uefa",
   "SUM(CASE WHEN s.currentTier = 'platinum' AND s.uefa = TRUE THEN 1 ELSE 0 END) AS platinum_clubs_uefa",
   "SUM(CASE WHEN s.currentTier = 'gold' THEN 1 ELSE 0 END) AS gold_clubs"
)

I have a tried a variety of <> TRUE , != TRUE and = FALSE but I haven't been able to pull the data I want out.我尝试了各种<> TRUE!= TRUE= FALSE但我无法提取我想要的数据。

The query that works when I query the PostgreSQL database manually is:当我手动查询 PostgreSQL 数据库时有效的查询是:

...AND uefa IS NOT TRUE;

How can I tweak this query to pull out non-truthy values from this boolean field?我如何调整此查询以从此 boolean 字段中提取非真实值?

composer show | grep doctrine                                                            
doctrine/annotations                 1.13.2             Docblock Annotations Parser
doctrine/cache                       2.1.1              PHP Doctrine Cache library is a popular cache implementation that supports many different drivers...
doctrine/collections                 1.6.8              PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.
doctrine/common                      3.3.0              PHP Doctrine Common project is a library that provides additional functionality that other Doctri...
doctrine/data-fixtures               1.5.3              Data Fixtures for all Doctrine Object Managers
doctrine/dbal                        2.13.8             Powerful PHP database abstraction layer (DBAL) with many features for database schema introspecti...
doctrine/deprecations                v0.5.3             A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable...
doctrine/doctrine-bundle             2.6.3              Symfony DoctrineBundle
doctrine/doctrine-fixtures-bundle    3.4.1              Symfony DoctrineFixturesBundle
doctrine/doctrine-migrations-bundle  3.0.3              Symfony DoctrineMigrationsBundle
doctrine/event-manager               1.1.1              The Doctrine Event Manager is a simple PHP event system that was built to be used with the variou...
doctrine/inflector                   2.0.4              PHP Doctrine Inflector is a small library that can perform string manipulations with regard to up...
doctrine/instantiator                1.4.1              A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer                       1.2.3              PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.
doctrine/migrations                  3.4.2              PHP Doctrine Migrations project offer additional functionality on top of the database abstraction...
doctrine/orm                         2.12.1             Object-Relational-Mapper for PHP
doctrine/persistence                 2.5.1              The Doctrine Persistence project is a set of shared interfaces and functionality that the differe...
doctrine/sql-formatter               1.1.2              a PHP SQL highlighting library
pg_config --version
PostgreSQL 12.9
psql --version
psql (PostgreSQL) 12.9

Instead of IS NOT TRUE , have you tried = FALSE ?你尝试过= FALSE而不是IS NOT TRUE吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM