Fetch all but some specified columns in partial load #6426

Open
opened 2026-01-22 15:33:01 +01:00 by admin · 1 comment
Owner

Originally created by @Phobetor on GitHub (Mar 16, 2020).

Feature Request

New syntax construct to allow specification of columns that should be excluded from the full result set in a partial load.

Q A
New Feature yes
RFC yes
BC Break no

Summary

Partial loads are very neat to avoid loading vast amounts of data when only some columns are required but you loose flexibility when doing so. Every new column which is added to an entity and then used at some place in the application which uses a partial load also requires to add it to the partial definition. This can lead to very lengthy query builder constructions.

I have some cases (admin overviews mostly) where I only want to exclude a very small amount of columns e. g. because they are BLOBs but I would like to keep all the other fields in the result.

To solve this I suggest to have some new syntax that allows to exclude columns from the partial load keeping all the other columns (not listed in the definition explicitly) in the result.

Example

Lets assume there is a table t with 10 columns (a,b,c,d,e,f,g,h,i,j) and I want to fetch all columns but i and j.

Currently the query builder would look like this:

$queryBuilder
    ->select(
        'partial t.{a,b,c,d,e,f,g,h}'
    );

Lets assume that partial t.{-…} is the syntax for the new column exclusion. Then the new query builder would look like this:

$queryBuilder
    ->select(
        'partial t.{-i,j}'
    );

Just table t without column i and j.

Originally created by @Phobetor on GitHub (Mar 16, 2020). ### Feature Request New syntax construct to allow specification of columns that should be excluded from the full result set in a partial load. | Q | A |------------ | ------ | New Feature | yes | RFC | yes | BC Break | no #### Summary Partial loads are very neat to avoid loading vast amounts of data when only some columns are required but you loose flexibility when doing so. Every new column which is added to an entity and then used at some place in the application which uses a partial load also requires to add it to the partial definition. This can lead to very lengthy query builder constructions. I have some cases (admin overviews mostly) where I only want to exclude a very small amount of columns e. g. because they are BLOBs but I would like to keep all the other fields in the result. To solve this I suggest to have some new syntax that allows to exclude columns from the partial load keeping all the other columns (not listed in the definition explicitly) in the result. Example -- Lets assume there is a table `t` with 10 columns (`a,b,c,d,e,f,g,h,i,j`) and I want to fetch all columns but `i` and `j`. Currently the query builder would look like this: ``` $queryBuilder ->select( 'partial t.{a,b,c,d,e,f,g,h}' ); ``` Lets assume that `partial t.{-…}` is the syntax for the new column exclusion. Then the new query builder would look like this: ``` $queryBuilder ->select( 'partial t.{-i,j}' ); ``` Just table `t` without column `i` and `j`.
Author
Owner

@aelamel commented on GitHub (Jul 10, 2020):

It would be great if we have this feature in doctrine.

@aelamel commented on GitHub (Jul 10, 2020): It would be great if we have this feature in doctrine.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6426