[6.x]: yii2-adapter: yii\db\Expression assigned to an ActiveRecord attribute becomes a JSON string
Maintainers usually reply within 1 day
@riasvdv is already working on this.
Since Oct 13, 2026.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
Start by tracing how yii\db\Expression is handled when assigned to an ActiveRecord attribute and passed through update(), comparing the Craft 5 and Craft 6 behavior described here. Reproduce with the shown assignment and MySQL 8.4.5; done means the column receives the expression result (today + 1) rather than its JSON representation. The issue names no source file or test, so locating the relevant code and a regression test will take project familiarity.
Written by the indexing model from the issue text.
Description
What happened?
Description
I’m testing a plugin for Craft 6 via yii2-adapter. I found a behavior change with yii\db\Expression.
This code works in the previous Craft version:
$record->today = new \yii\db\Expression('today + 1');
$record->update();
in craft 5, var_dump($record->today) shows an Expression object:
object(yii\db\Expression)#572 (2) { ["expression"]=> string(9) "today + 1" ... }
In Craft 6, the same dump shows a JSON string:
string(38) "{"expression":"today + 1","params":[]}"
update() returns 1. But the column gets that JSON text, not today + 1. So the counter never increases.
I’m not sure this is related to Craft 6. It may be caused by something else in my setup or plugin.
Thanks!
Craft CMS version
6.0.0-alpha.20
PHP version
No response
Operating system and version
No response
Database type and version
MySQL 8.4.5
Image driver and version
No response
Installed plugins and versions
- vnali/craft-counter
- Dominant language
- PHP
- Stars
- 3.6k
- Forks
- 706
- Avg merge
- 11h 2m
- Merged PRs (30d)
- 252
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from craftcms/cms
-
[5.x]: Renaming an asset without the file extension fails with “” is not an allowed file extension.Openbug repo:cms
Difficulty 3/5 1-2 days Newbie friendliness 55/100
craftcms/cms#19950 · 1 comment ·
Maintainers usually reply within 1 day
-
[6.x]: Text in some input fields is clipped at the bottom on WindowsPossibly taken @brianjhanson claimed this 5 days ago. Openbug repo:cms
craftcms/cms#19928 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
bug repo:cms
Difficulty 4/5 3-5 days Newbie friendliness 15/100
craftcms/cms#19916 · 1 comment ·
Maintainers usually reply within 1 day
-
[6.x]: AdminTable not available for plugin index and settings screensPossibly taken @brianjhanson claimed this 6 days ago. Openbug repo:cms
craftcms/cms#19912 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
[6.x]: No way for custom element types to add top level buttons in toolbar or beside the Save menuPossibly taken @brianjhanson claimed this 5 days ago. Openbug repo:cms
Difficulty 5/5 Over a week Newbie friendliness 15/100
craftcms/cms#19910 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
Similar issues
-
feature request
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Automattic/blocks-engine#2803 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
hestiacp/hestiacp#5798 · 2 comments ·
Maintainers usually reply within 1 day
-
Bug Component: HTTP Component: Telemetry
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
woocommerce/woocommerce-google-analytics-integration#699 ·
Maintainers usually reply within 1 day