Code Monkey home page Code Monkey logo

query-bundle's People

Contributors

alessandrominoccheri avatar orociscaverai avatar sensomado avatar sensorario avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

query-bundle's Issues

Limit = -1 for no limit results

Q A
Bug report? no
Feature request? yes
QueryBundle version 2.3.3

Is it possible like DataTables put in the request limit = -1

for no limit results?

Example:

&limit=-1

So we can avoid: &limit=999999

missing documentation to write complex query like this:

?filtering[_embedded.building.bundledIds|contains|1]=3d531c15
&filtering[_embedded.building.bundledIds|contains|2]=65635e7b
&filtering[_embedded.building.codiceRegione|eq]=01
&filtering[_embedded.building.denominazioneProvincia|eq]=Cuneo
&filtering[_embedded.building.id|eq]=492
&filtering[_embedded.building.id|eq]=91dd9bf8
&filtering[_embedded.contractState|eq]=33
&filtering[_embedded.remarketingState.id|eq]=821a85ca
&filtering[_embedded.actManager.id|eq]=603e88b7
&filtering[salePrice|gte]=10
&filtering[salePrice|lte]=100
&filtering_or[_embedded.conductorCorporateName|contains]=dfsd
&filtering_or[_embedded.contractCode|contains]=dfsd
&filtering_or[code|contains]=dfsd
&limit=25
&page=1
&rel=building,buildingUsers,groups,buildingUnits,contract,expertises,location,sales,actManager

missing query string variables

These three methods

  • BaseRepository::setQueryOptionsFromRequest()
  • BaseRepository::setQueryOptionsFromRequestWithCustomFilter()
  • BaseRepository::setQueryOptionsFromRequestWithCustomOrFilter()

defines QueryBuilderOptions object with query string variables. Only BaseRepository::setQueryOptionsFromRequest() contains this snippet:

    $requestAttributes = [];
    foreach ($request->attributes->all() as $attributeName => $attributeValue) {
        $requestAttributes[$attributeName] = $request->attributes->get(
            $attributeName,
            $attributeValue
        );
    }

It get all current request variables and pass them to the QueryBuilderOptions. This may cause some problem if a resource that uses the query-bundle require a variable that is not in the list:

        'filtering'   => $filtering,
        'orFiltering' => $filterOrCorrected,
        'limit'       => $limit,
        'page'        => $page,
        'filters'     => $filters,
        'orFilters'   => $filterOrCorrected,
        'sorting'     => $sorting,
        'rel'         => $rel,
        'printing'    => $printing,
        'select'      => $select, 

Annotation for field that can't be filtered

Q A
Bug report? no
Feature request? yes
QueryBundle version 2.4

Create an entity annotation on its fields to declare if that field can't be filtered so if a request try to filter with that field the query bundle remove automatically that filter for example the field password. Now that can be done into the request listener but I think is better to Do it into the entity

Objects\Operator

In version 1.0.7 were introduces Vocabulary/Operators that contains all operator definitions. But definitions ara still arrays. As developer I would an Operator object. The final purpose of this Object is also to remove $whereCondition string in favour a Objects\WhereCondition object.

Test improvement

Hello everybody,
I would like to cover all the repository with tests.

What do you think top open a Pull request on WIP and split It into different task for every class for example?

It could be interest to integrate travis for CI or some similar tool to do It

Let me know

getEntityAlias function doesn't exists

Q A
Bug report? yes
Feature request? no
QueryBundle version 2.2.x

If you use buildSelectValue from QueryBuilderFactory and you are not set selectIt calls $this->getEntityAliasfunction that doesn't extsts

Mandatory parameters missing when generate url

When inside an url like this:

entities/{id}/someAction

returns this error when is use inside the repository paginateResults() method:

Some mandatory parameters are missing (\"id\") to generate a URL for route \"app_entity_getentity\".",

The solution now is to overwrite the function customQueryStringValues inside the repository like this:

public function customQueryStringValues()
    {
        return['id'];
    }

But It could be better to autodetection url parameters

Get result without pagination

Is possible to have a single result without pagination?

Example: I need to get a specific record by Id with custom filter not passed by url.

I would like to do something like this:

            $filters['id|eq'] = $id;
            $filters['myCustomFilter|eq] = 'foo';

            $result = $this->getDoctrine()
                ->getRepository('AppBundle:Entity')
                ->setRequestWithFilter($request, $filters)
                ->getResult(); //or find

remove Queries\Objects\Operator classs

Q A
Bug report? no
Feature request? no
QueryBundle version 2.4

Object Queries\Objects\Operator was marked as deprecated in version 2.3. Now should be removed.

add `QueryBuilderFactory::findOne();` method

Whenever result could be a single item

$filters['id|eq'] = $id;
$entity = $this->getDoctrine()
  ->getRepository('AppBundle:Table')
  ->setRequestWithFilter($request, $filters)
  ->findAllPaginated();

we actually need to intercept response with pagination data and keep just first _embedded value:

$response = $this->createApiResponse($entity, 200)->getContent();

$responseClean = json_decode($response, true);
$content = $responseClean['_embedded']['items'][0];

and finally return the content

return new JsonResponse($content);

Missing coverage badge

When this snippet stops to be "unknown" can be added to readme file ^_^!

[![Code Coverage](https://scrutinizer-ci.com/g/studiomado/query-bundle/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/studiomado/query-bundle/?branch=master)

Code Coverage

"and" as alias of "filtering" and "or" as alias of "filtering_or"

It could be better if a query like

?filtering[bar|op1]=value1&filtering[foo|op2]=value2

could be writeable as

?and[bar|op1]=value1&and[foo|op2]=value2

from query string and as {"and|or": {"bar": {"op1": "value1"},"foo": {"op2": "value2"}}}

{
    "and|or": {
        "bar": {
            "op1": "value1"
        },
        "foo": {
            "op2": "value2"
        }
    }
}

So then we'll query api directly with json.

Configure branch alias

We also need to add this lines in composer.json file. This fix shows in packagist.org the development version instead of "dev-master". It's important to show what are version(s) in development. Once we've "finished" version 1.0 we can bump to version 1.1 and fix these lines.

"extra": {
    "branch-alias": {
        "dev-master": "1.0-dev"
    }
},

Change the way queryOption is created in BaseRepository

These three methods contains repeated code and looks like factory method that can be moved out from here or simply improved in design.

BaseRepository::setQueryOptionsFromRequest()
BaseRepository::setQueryOptionsFromRequestWithCustomFilter()
BaseRepository::setQueryOptionsFromRequestWithCustomOrFilter()

According to a BC promise, I'll suggest to leave these methods, set them as deprecated (removed in version 2.0), and finally to add new factory here or in a new class for next minor release.

"Minor releases (such as 2.5, 2.6 etc.) may introduce new features, but must do so without breaking the existing API of that release branch (2.x in the previous example)."

Get response function with relation in query string

Q A
Bug report? no
Feature request? yes
QueryBundle version 2.4

We can add the possibility to return a serialized and standard response with Its relations passed into query string.
Something like getResponse() because when you create a new project you need to copy always the same function to get your correct serialized, standard response.
I mean this code:

protected function createApiResponse($data, $statusCode = 200, $groups = [])
    {
        $requestStack = $this->get('request_stack');
        $serializer = $this->get('jms_serializer');

        $groups = array_merge(['Default'], $groups);
        $groups = array_merge($groups, explode(',', $requestStack->getCurrentRequest()->query->get('rel', 'Default')));
        $groups = array_unique($groups);

        $json = $serializer->serialize(
            $data,
            'json',
            SerializationContext::create()
                ->enableMaxDepthChecks()
                ->setGroups($groups)
        );

        return new Response($json, $statusCode, array(
            'Content-Type' => 'application/json',
        ));
    }

What do you think?

Notice: Undefined index: list

Q A
Bug report? yes
Feature request? no
QueryBundle version 2.2

An additional filters can be one of listed in the Dictionary (array_keys(Dictionary::getOperators())). Actually is always 'list' and not accept different values inside Mado\QueryBundle\Queries\Objects\Value::class.

AddRelation method

Q A
Bug report? no
Feature request? yes
QueryBundle version master

It could be nice to add relation with a method not only from query string

Separate or filter conditions

Q A
Bug report? no
Feature request? yes
QueryBundle version 2.4

It could be very useful to create a query with more or filter conditions separated like this:

select * from entity WHERE name = 'foo' OR surname = 'baz' OR description = 'bar'  OR subject = 'buzz';

The purpose is to have something like this:

select * from entity WHERE (name = 'foo' OR surname = 'baz') AND (description = 'bar'  OR subject = 'buzz');

[QueryOptionsBuilder]

Q A
Bug report? no
Feature request? yes
QueryBundle version 2.5

Move the responsibility to build the QueryBuilderOptions out from BaseRepository.

which php version? how many version we would support?

Until now we have been worked without care about php version. Starting from v2.2.10 php version is forced to 7.0 because some software works with that version. According to this fact we can still mantains version 2.2 but also develop new version against most recent php71 version.

version supported versions
2.2 7.0.8
master >= 7.1

Two version could be always maintained: 2.2 and master. Each bug found in version 2.2 will be merged to master.

/cc @AlessandroMinoccheri @davidedonattini @mmedelin @simocheccoli @orociscaverai

Bundle dependencies

I would say in the composer.json the dependencies with the other bundles such as: JMS, Doctrine, HATEOS, PagerFanta

Enhance QueryBuilderOptions for different purposes

Q A
Bug report? no
Feature request? yes
QueryBundle version 2.5

Actually QueryBuilderOptions is used for both CLI and HTTP interfaces. It is used mainly in controllers. This means that it must be built within a request. This suggest a "RequestQueryBuilderOption" component. Also, ... a "CLIQueryBuilderOption" should exists. These names are just ideas.

            └── QueryBuilderOptions
                       ├── ...
                       ├── CliOptions
                       └── HttpOptions

This could affect also BaseRepository and all its initializers. We may also have a CliBaseRepository and or HttpBaseRepository?

/cc @orociscaverai @AlessandroMinoccheri

Null value passed into filter parameters

Q A
Bug report? yes
Feature request? no
QueryBundle version master

When a filter with null value is passed the query must be change from this:

table.field = NULL

to this:

table.field IS NULL

Filtering or with left join

Q A
Bug report? yes
Feature request? no
QueryBundle version master

Is necessary to change inner join to left join when a filter or is applied, because some relations can be null so now there aren't retrieved

DijkstraWalker is final and canno be mocket

Q A
Bug report? no
Feature request? yes
QueryBundle version 2.1

DijkstraWalker is final. This is ok because we should not overwrite some behavior. But we also need to mock DijkstraWalker. We need an interface that leave DijkstraWalter final but allow us to create mock of a walker.

Use Mysql without MariaDB

Q A
Bug report? yes
Feature request? yes
QueryBundle version master

It would be great that you can use query-bundle with only mysql and not only with MariaDB

keep just one clean version (starting from version v2.5.0)

We have more version alive. I suggest to move everything to a new v2.5.0 and keep mantained just this instead of:

  • 2.2
  • 2.3
  • 2.4

main issue here is that earlier versions use php 7.1 or 7.2 features. But this library works also with php 7.0 or older version. Because of it is hard and wasteful to spend time to keep versions maintained together, just one version could be a good solution.

Sorting on 2nd level embedded it crashes

Q A
Bug report? yes
Feature request? no
QueryBundle version 2.2.16-RC17

Sorting on 2nd level embedded it crashes

?sorting[_embedded.customer.macrocategory.descrizione_macrocatyegory]=asc

Instead filtering with the same field it works
?filtering[_embedded.customer.macrocategory.descrizione_macrocatyegory|contains]=aaa

ERROR

{"code":500,"message":"[Semantical Error] line 0, col 234 near 'macrocategory': Error: Class GammaBundle\\Entity\\Macrocategory has no field or association named macrocategory"}

LOG

[2018-06-14 09:46:50] request.CRITICAL: Uncaught PHP Exception Doctrine\ORM\Query\QueryException: "[Semantical Error] line 0, col 234 near 'macrocategory': Error: Class GammaBundle\Entity\Macrocategory has no field or association named macrocategory" at /home/vagrant/mt-api/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php line 63 {"exception":"[object] (Doctrine\ORM\Query\QueryException(code: 0): [Semantical Error] line 0, col 234 near 'macrocategory': Error: Class GammaBundle\Entity\Macrocategory has no field or association named macrocategory at /home/vagrant/mt-api/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php:63, Doctrine\ORM\Query\QueryException(code: 0): SELECT s FROM StockSelloutBundle\Entity\Stock s INNER JOIN s.customer table_customer INNER JOIN table_customer.macrocategory table_macrocategory WHERE s.year = :field_year_827 AND s.week = :field_week_467 ORDER BY table_macrocategory.macrocategory asc at /home/vagrant/mt-api/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php:41)"} []

better filters names

Q A
Bug report? yes
Feature request? yes
QueryBundle version 2.2

Here we have two kind of filters:

  • and
  • or

Actually exists setFilters method (for and case) and setOrFilters method (for or case). It could be better if also And filters become explicit.

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.