Skip to content

Conversation

@p-bystritsky
Copy link
Contributor

Original pull request: #17915

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)

@magento-engcom-team
Copy link
Contributor

Hi @p-bystritsky. 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 2.3-develop instance - deploy vanilla Magento instance

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

@VladimirZaets
Copy link
Contributor

Hi @p-bystritsky. The PR with the port for this issue was already created.
Thanks

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.

3 participants