sonata-project / SonataDoctrineMongoDBAdminBundle

Symfony Sonata / Integrate Doctrine MongoDB ODM into the SonataAdminBundle
https://docs.sonata-project.org/projects/SonataDoctrineMongoDBAdminBundle
MIT License
65 stars 95 forks source link

String filter wrong query on sub document #158

Closed zajca closed 4 years ago

zajca commented 8 years ago

When sub document is used like in documentation:

->add('address.town')

wrong query is executed:

db.Place.find({ "town": new RegExp("New York", "i") }).skip(0).limit(0).sort({ "_id": 1 });

searched property is town not address.town

OskarStark commented 8 years ago

which versions are you using? can you please post the output of composer show - i

zajca commented 8 years ago

Sorry I bit forget this :/

I'm using latest master with patch to make it work with symfony 3.

$ composer show -i 
behat/transliterator                         v1.1.0                       String transliterator
cocur/slugify                                v2.1.1                       Converts a string into a slug.
doctrine/annotations                         v1.2.7                       Docblock Annotations Parser
doctrine/cache                               v1.6.0                       Caching library offering an object-oriented API for many cache backends
doctrine/collections                         v1.3.0                       Collections Abstraction library
doctrine/common                              v2.6.1                       Common Library for Doctrine projects
doctrine/data-fixtures                       v1.2.0                       Data Fixtures for all Doctrine Object Managers
doctrine/dbal                                v2.5.4                       Database Abstraction Layer
doctrine/doctrine-bundle                     1.6.3                        Symfony DoctrineBundle
doctrine/doctrine-cache-bundle               1.3.0                        Symfony Bundle for Doctrine Cache
doctrine/doctrine-fixtures-bundle            2.3.0                        Symfony DoctrineFixturesBundle
doctrine/inflector                           v1.1.0                       Common String Manipulations with regard to casing and singular/plural rules.
doctrine/instantiator                        1.0.5                        A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer                               v1.0.1                       Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
doctrine/mongodb                             1.3.0                        Doctrine MongoDB Abstraction Layer
doctrine/mongodb-odm                         1.1.0                        Doctrine MongoDB Object Document Mapper
doctrine/mongodb-odm-bundle                  dev-master 97ac93c           Symfony2 Doctrine MongoDB Bundle
facebook/php-sdk-v4                          5.2.0                        Facebook SDK for PHP
friendsofsymfony/rest-bundle                 dev-master c1b87d9           This Bundle provides various tools to rapidly develop RESTful API's with Symfony
fzaninotto/faker                             v1.6.0                       Faker is a PHP library that generates fake data for you.
gedmo/doctrine-extensions                    v2.4.13                      Doctrine2 behavioral extensions
guzzlehttp/guzzle                            6.2.0                        Guzzle is a PHP HTTP client library
guzzlehttp/promises                          1.2.0                        Guzzle promises library
guzzlehttp/psr7                              1.3.0                        PSR-7 message implementation
hautelook/alice-bundle                       dev-master ca01f32           Symfony2 Bundle to manage fixtures with Alice and Faker.
imagine/imagine                              v0.6.3                       Image processing for PHP 5.3
incenteev/composer-parameter-handler         v2.1.2                       Composer script handling your ignored parameter file
ismaambrosi/generator-bundle                 v2.5.0                       Generates Symfony2 documents, forms and CRUD
jdorn/sql-formatter                          v1.2.17                      a PHP SQL highlighting library
jms/metadata                                 1.5.1                        Class/method/property metadata management in PHP
jms/parser-lib                               1.0.0                        A library for easily creating recursive-descent parsers.
jms/serializer                               1.1.0                        Library for (de-)serializing data of any complexity; supports XML, JSON, and YAML.
jms/serializer-bundle                        1.1.0                        Allows you to easily serialize, and deserialize data of any complexity
knplabs/knp-menu                             v2.1.1                       An object oriented menu library
knplabs/knp-menu-bundle                      v2.1.1                       This bundle provides an integration of the KnpMenu library
liip/imagine-bundle                          1.5.3                        This Bundle assists in imagine manipulation using the imagine library
michelf/php-markdown                         1.6.0                        PHP Markdown
monolog/monolog                              1.19.0                       Sends your logs to files, sockets, inboxes, databases and various web services
nelmio/alice                                 2.1.4                        Expressive fixtures generator
nelmio/api-doc-bundle                        2.13.0                       Generates documentation for your REST API from annotations
ocramius/proxy-manager                       1.0.2                        A library providing utilities to generate, instantiate and generally operate with Object Proxies
paragonie/random_compat                      v2.0.2                       PHP 5.x polyfill for random_bytes() and random_int() from PHP 7
phpcollection/phpcollection                  0.4.0                        General-Purpose Collection Library for PHP
phpoption/phpoption                          1.5.0                        Option Type for PHP
psr/http-message                             1.0                          Common interface for HTTP messages
psr/log                                      1.0.0                        Common interface for logging libraries
robertotru/to-inline-style-email-bundle      dev-master 9db8d47           A Symfony2 bundle for using the CssToInlineStyles translator by tijsverkoyen
sensio/distribution-bundle                   v5.0.6                       Base bundle for Symfony Distributions
sensio/framework-extra-bundle                v3.0.16                      This bundle provides a way to configure your controllers with annotations
sensio/generator-bundle                      v3.0.7                       This bundle generates code for you
sensiolabs/security-checker                  v3.0.2                       A security checker for your composer.lock
sonata-project/admin-bundle                  3.3.1                        The missing Symfony Admin Generator
sonata-project/block-bundle                  3.0.1                        Symfony SonataBlockBundle
sonata-project/cache                         1.0.7                        Cache library
sonata-project/core-bundle                   3.0.3                        Symfony SonataCoreBundle
sonata-project/doctrine-mongodb-admin-bundle dev-symfony3-support c7ab549 Symfony Sonata / Integrate Doctrine MongoDB ODM into the SonataAdminBundle
sonata-project/exporter                      1.5.0                        Lightweight Exporter library
stof/doctrine-extensions-bundle              v1.2.2                       Integration of the gedmo/doctrine-extensions with Symfony2
swiftmailer/swiftmailer                      v5.4.2                       Swiftmailer, free feature-rich PHP mailer
symfony/monolog-bundle                       2.11.1                       Symfony MonologBundle
symfony/phpunit-bridge                       v2.8.7                       Symfony PHPUnit Bridge
symfony/polyfill-intl-icu                    v1.2.0                       Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring                    v1.2.0                       Symfony polyfill for the Mbstring extension
symfony/polyfill-php56                       v1.2.0                       Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70                       v1.2.0                       Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-util                        v1.2.0                       Symfony utilities for portability of PHP codes
symfony/security-acl                         v3.0.0                       Symfony Security Component - ACL (Access Control List)
symfony/swiftmailer-bundle                   v2.3.11                      Symfony SwiftmailerBundle
symfony/symfony                              v3.0.7                       The Symfony PHP framework
tijsverkoyen/css-to-inline-styles            1.5.5                        CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very useful when you're sending emails.
twig/extensions                              v1.3.0                       Common additional features for Twig that do not directly belong in core
twig/twig                                    v1.24.1                      Twig, the flexible, fast, and secure template language for PHP
vich/uploader-bundle                         1.0.0                        Ease file uploads attached to entities
willdurand/jsonp-callback-validator          v1.1.0                       JSONP callback validator.
willdurand/negotiation                       v2.0.2                       Content Negotiation tools for PHP provided as a standalone library.
zendframework/zend-code                      2.6.3                        provides facilities to generate arbitrary code using an object oriented interface
zendframework/zend-eventmanager              3.0.1                        Trigger and listen to events within a PHP application
zajca commented 8 years ago

Just tryied with lastest 3.x branch and still same: document:

class Place
{
...
    /**
     * @ODM\EmbedOne(targetDocument="MyBundle\Document\Address")
     */
    protected $address;
...
}

class Address
{
...
    /**
     * @ODM\Field(name="city", type="string")
     */
    protected $city;
...
}

admin:

$datagridMapper->add('address.city')

query:

db.Place.find({ "city": new RegExp("praha", "i") }).skip(0).limit(0).sort({ "_id": 1 });

when I have bit of time I'll try to create test for this.

franmomu commented 4 years ago

This should be fixed with https://github.com/sonata-project/SonataDoctrineMongoDBAdminBundle/pull/331, if not, feel free to open it again.