Skip to content

Conversation

@magently
Copy link

@magently magently commented Sep 4, 2018

Title

Fix Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection method addExpressionFieldToSelect result gets overwritten by addFieldToSelect.

Description

Fix Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection method addExpressionFieldToSelect result gets overwriten if called before addFieldToSelect. It happened in _initSelectFields method, if some columns were set before that method call they were overwirtten by it.
I changed the behaviour of addExpressionFieldToSelect method to not modify columns and instead insert expression into _fieldsToSelect private variable (same as addFieldToSelect does).

Fixed Issues (if relevant)

  1. addExpressionFieldToSelect has to be called after all addFieldToSelect #17635: addExpressionFieldToSelect has to be called after all addFieldToSelect

Manual testing scenarios

-create a collection
$bookingCollection = $this->_bookingCollectionFactory->create();
$bookingCollection->addExpressionFieldToSelect('stime_part', 'time(start_time)', []);
$bookingCollection->addFieldToSelect('finish_time', 'finish_date');

Expected result after the fix.
Field 'stime_part' populated with calculated data.

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

Magently added 2 commits August 24, 2018 16:58
Changed test method to fit the new implementation of the class method
@magento-engcom-team
Copy link
Contributor

Hi @magently. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me {$VERSION} instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

@sidolov
Copy link
Contributor

sidolov commented Sep 4, 2018

Hi @magently , please, update the PR with the issue description and steps to reproduce, otherwise, we can't proceed with your PR.
Thank you!

@magently
Copy link
Author

magently commented Sep 4, 2018

Sorry about the description, i was certain i filled it before. Updated

@magento-engcom-team magento-engcom-team added this to the Release: 2.2.8 milestone Oct 3, 2018
@magento-engcom-team
Copy link
Contributor

Hi @slavvka, thank you for the review.
ENGCOM-3086 has been created to process this Pull Request

@magento-engcom-team
Copy link
Contributor

Hi @magently. Thank you for your contribution.
We will aim to release these changes as part of 2.2.8.
Please check the release notes for final confirmation.

Please, consider to port this solution to 2.3 release line.
You may use Porting tool to port commits automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants