Skip to content

Conversation

@fetus-hina
Copy link
Contributor

Q A
Is bugfix?
New feature? ✔️
Breaks BC?
Fixed issues None

Enhanced ArrayDataProvider::prepareKeys() to use ArrayHelper::getColumn() for extracting each keys. This change enables more flexible key specifications, including:

  • Dot-separated paths (e.g. foo.bar)
  • Arrays of keys (e.g. ['foo', 'bar'])

This enhancement allows easier and more versatile key definitions from input data, while preserving existing string and callable usage.

This will be useful when formatting data from somewhat complex arrays ---- for example, those created using ActiveQuery::find()->with()->asArray()->all().

@codecov
Copy link

codecov bot commented Aug 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.49%. Comparing base (2fc017b) to head (542f2d8).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #20505      +/-   ##
============================================
+ Coverage     64.48%   64.49%   +0.01%     
+ Complexity    11576    11574       -2     
============================================
  Files           433      433              
  Lines         37610    37605       -5     
============================================
+ Hits          24252    24253       +1     
+ Misses        13358    13352       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Enhanced `ArrayDataProvider::prepareKeys()` to use `ArrayHelper::getColumn()` for extracting model keys.
This change enables more flexible key specifications, including:

- Dot-separated paths (e.g. `foo.bar`)
- Arrays of keys (e.g. `['foo', 'bar']`)

This enhancement allows easier and more versatile key definitions from input data, while preserving existing string and callable usage.
@fetus-hina fetus-hina force-pushed the array-data-provider-keys branch from c54826e to 09d011f Compare August 28, 2025 10:20
@samdark
Copy link
Member

samdark commented Aug 29, 2025

Is it fully backwards compatible? If so, need a line for CHANGELOG added. Looks interesting.

@fetus-hina
Copy link
Contributor Author

fetus-hina commented Aug 30, 2025

Thank you,

Is it fully backwards compatible?

Yes. It is fully backward-compatible.

  • When the array has simple string keys, it behaves as expected.
  • When the array has string keys that include dots, ArrayHelper::getColumn() -> ArrayHelper::getValue() first checks whether the entire key exists, so it behaves the same as with simple string keys. (e.g., "foo.bar", it first looks for $item['foo.bar'] and then falls back to $item['foo']['bar'], so there’s no compatibility break here.)
  • When the key is a callable, the function signature passed from ArrayHelper::getColumn() -> ArrayHelper::getValue() is the same as in the original implementation, so it behaves identically.

@samdark samdark added this to the 2.0.54 milestone Aug 30, 2025
@samdark samdark merged commit 9b417e5 into yiisoft:master Aug 30, 2025
96 checks passed
@samdark
Copy link
Member

samdark commented Aug 30, 2025

Thank you!

@fetus-hina fetus-hina deleted the array-data-provider-keys branch August 31, 2025 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants