Giter Site home page Giter Site logo

zfcampus / zf-doctrine-querybuilder Goto Github PK

View Code? Open in Web Editor NEW

This project forked from api-skeletons/zf-doctrine-querybuilder

32.0 32.0 19.0 941 KB

Doctrine Query Builder request Filters

License: BSD 3-Clause "New" or "Revised" License

PHP 96.65% HTML 3.35%

zf-doctrine-querybuilder's People

Contributors

baptistemanson avatar brunomaurice avatar dorongutman avatar fabiocarneiro avatar fabiopaiva avatar hounddog avatar jeremiahsmall avatar jguittard avatar lweijl avatar matwright avatar michalbundyra avatar mrvralex avatar neeckeloo avatar pietervogelaar avatar powerkiki avatar serhiikushch avatar thinkscape avatar tomhanderson avatar veewee avatar weierophinney avatar wowo avatar zluiten avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zf-doctrine-querybuilder's Issues

Error when enter none existing filed name in filtering

Hi all,

I am using your moduel and first of all I must say that it is great. Today I encountered situation that I cannot handle so please direct me the right way, if it is a bug or just my lack of knowlage. I am using ZF3 with:

"zfcampus/zf-apigility-doctrine": "^2.2",
"zfcampus/zf-doctrine-querybuilder": "^1.6",
"doctrine/doctrine-orm-module": "^1.1",

The reason why I am doing this is that my app has a API module but most of it has normal UI. When I try to filter like this:

domain.com/api/transaction?filter[0][type]=eq&filter[0][field]=name&filter[0][value]=test

Everything is fine. But when I try to do something like this:

domain.com/api/transaction?filter[0][type]=eq&filter[0][field]=fdsafdsafds&filter[0][value]=test

I get this message:

{
    "error": "[Semantical Error] line 0, col 68 near 'skdjbvkdjvb =': Error: Class Application\\Entity\\Client\\Transaction has no field or association named skdjbvkdjvb"
}

Which is 100% true, but I would like to hide application information like namespaces etc and not show them to the world. Also when I try this:

domain.com/api/transaction?filter[0][type]=eq&filter[0][fieldName]=fdsafdsafds&filter[0][value]=test

I get this message:

{
    "error": "[Syntax Error] line 0, col 69: Error: Expected Doctrine\\ORM\\Query\\Lexer::T_IDENTIFIER, got '='"
}

Which is also not very nice from secutiry point of view. I red your documentation and crawled the code and I cannot find a solution how to change the output when someone will try to break my application adding incorrect URL params. Thank you.

Maintaining this repository

It's been over a year since anything was merged into this repo. Will someone please step up to maintain it? I volunteer if nobody else is going to take the job.

This repository needs a rewrite

This repo was written in the context of Apigility. It is very useful in Apigility but the name of this repository and what it does best is to populate a QueryBuilder based on an array. For instance this is used in api-skeletons/zf-doctrine-graphql where Apigility shouldn't be a requirement.

Specific problems

  • Hydrator\Strategy\CollectionLink is specific to Apigility. This strategy is duplicated in api-skeleletons/zf-doctrine-hydrator (which also has strategies in the same tool type as this strategy)
  • Query Providers are specific to Apigility. I think these classes would do well in their own repository.

And with these out of the way this repo can do the job of array > Query Builder cleanly.

I'm willing to do this for a cleaner repo. What do you say?

DefaultO*mFactory expects root service manager - BC BREAK

Not covered in the unit tests is all filters are created through

ZF\Doctrine\QueryBuilder\Filter\Service\O*MFilterManger so this is the ServiceLocator passed
to https://github.com/zfcampus/zf-doctrine-querybuilder/blob/master/src/Query/Provider/DefaultOrmFactory.php#L22

The unit tests are written as though there is only the root ServiceLocator/ServiceManger and not considered is all Filters are inside a Zend\ServiceManager\AbstractPluginManager

This is a BC Break and causes the DefaultO*MFactoryies to be useless inside zf-apigility-doctrine.

On the unit tests, a single-level ServiceLocator is created to pass to the Factories: https://github.com/zfcampus/zf-doctrine-querybuilder/blob/master/test/Query/Provider/DefaultOrmFactoryTest.php#L18

And inside the Factories they should either be passed the system ServiceManager or the instance of ZF\Doctrine\QueryBuilder\Filter\Service\O*MFilterManager which would then be queried inside the Factories for the ServiceLocator.

HowTo request: Integrate with more generic PSR-7 based framework(s)

I've used this module previously in Apigility project. Now I have a adopted a Slim-based project that has doctrine backed entities.

A few things I've noticed ... installing this installs a universe of Apigility-centric modules. Assuming that one intends to use this in something like Slim or Expressive ... this seems like a lot of class overhead for the ability to take in query-string arguments to manipulate the doctrine QueryBuilder's output.

Are there plans to get this module leaned out and a bit more generic for the PSR-7 projects?

Packagist sync

I think the repo settings are not updated to sync it with packagist. A tag was created 20 minutes ago and it's not available yet on packagist.

Semantically "isNull" does not map to "field:{$exists:false)", "field:null" is better

IsNull.php:22
$queryBuilder->$queryType($queryBuilder->expr()->field($option['field'])->exists(false));

If I have a field in my document, "foo" that is set to null, I would expect that filtering as follows:

[
   'field' => 'foo',
   'filter' => 'isNull'
]

Would return my document, but it doesn't. This is the query that runs:

db.getCollection('myCollection').find({foo:{$exists:false}})

I suggest that a much better match would be:

db.getCollection('myCollection').find({foo:null})

If a field is marked as null then it DOES exist and doesn't return. By searching for a null we cover both cases: the case where the field doesn't exist AND the case where the field really IS null.

I already fixed it for isNull, isNotNull ODM filters, I'm just raising this as an issue here in case I missed something? I can put in a pull request if there are no objections.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.