zfcampus / zf-doctrine-querybuilder Goto Github PK
View Code? Open in Web Editor NEWThis project forked from api-skeletons/zf-doctrine-querybuilder
Doctrine Query Builder request Filters
License: BSD 3-Clause "New" or "Revised" License
This project forked from api-skeletons/zf-doctrine-querybuilder
Doctrine Query Builder request Filters
License: BSD 3-Clause "New" or "Revised" License
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.
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.
Use zf-apigility-doctrine as a templete.
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
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?
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*MFactory
ies 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.
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?
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.
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.
So, see topic.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.