Skip to content

Add Expression::exprNow() support for all DB platforms - #1311

Merged
mvorisek merged 67 commits into
developfrom
feature/exprnow-for-sqllite
Oct 10, 2026
Merged

mvorisek merged 67 commits into
developfrom
feature/exprnow-for-sqllite

Conversation

@DarkSide666

@DarkSide666 DarkSide666 commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

No description provided.

@DarkSide666
DarkSide666 requested a review from mvorisek October 5, 2026 18:51
@mvorisek
mvorisek removed their request for review October 7, 2026 08:13
@mvorisek

mvorisek commented Oct 7, 2026

Copy link
Copy Markdown
Member

I have looked into this - there is no functional test - please add one into SelectTest.

I would like to have both the SQL query/string and the result (matching format) asserted for every database.

Preferably with at least 6/microseconds precision.

The format should be unified for all DB vendors and parsable using regular DBAL datetime type.

]);
}

public function testExprNow(): void

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In SelectTest there should be no Model/DBAL (typecasting) usage.

Test here somethings like "SELECT $e->exprNow()". You can you $this->debug = true; for debugging the sent queries.

Once you get results/formats you want, assert the sent query, see JSON testing for example, you will have to expect different strings for some engines.

Once you have this raw querying working, only then bother with Model/DBAL, otherwise you will have too many layers to debug at once.

@DarkSide666

Copy link
Copy Markdown
Member Author

Looks like DBAL itself is quite broken with DATETIME and microseconds. Some engines partly support that, migrator mostly don't support and ... well, it's mostly DBAL which strips .u from datetime.

@DarkSide666
DarkSide666 marked this pull request as draft October 7, 2026 11:17
@mvorisek

mvorisek commented Oct 9, 2026

Copy link
Copy Markdown
Member

The DBAL limitation is tracked in #1313. Easy to fix in DBAL, but quite hard to fix in atk4/data. I have not enough time to support DBAL workarounds for everything...

This PR is hovewer perfect itself and once the tests are green I will merge it. Thank you for all the great ideas ❤, I basically only reviewed them ;-)

@mvorisek
mvorisek marked this pull request as ready for review October 9, 2026 19:32
@mvorisek
mvorisek marked this pull request as draft October 9, 2026 19:33
@mvorisek
mvorisek force-pushed the feature/exprnow-for-sqllite branch from bd713fe to 6251004 Compare October 9, 2026 19:41
@mvorisek
mvorisek force-pushed the feature/exprnow-for-sqllite branch from 6251004 to 0c5f900 Compare October 9, 2026 22:02
@mvorisek
mvorisek force-pushed the feature/exprnow-for-sqllite branch from 0c5f900 to f72e66f Compare October 9, 2026 22:14
@mvorisek
mvorisek force-pushed the feature/exprnow-for-sqllite branch from f72e66f to 67189d5 Compare October 9, 2026 23:37
@mvorisek
mvorisek force-pushed the feature/exprnow-for-sqllite branch from 67189d5 to c2c0de4 Compare October 10, 2026 08:33
@mvorisek
mvorisek marked this pull request as ready for review October 10, 2026 08:35
@mvorisek mvorisek changed the title Fix Expression::exprNow() support for all DB platforms Add Expression::exprNow() support for all DB platforms Oct 10, 2026
@mvorisek
mvorisek merged commit bfd0d0c into develop Oct 10, 2026
33 of 38 checks passed
@mvorisek
mvorisek deleted the feature/exprnow-for-sqllite branch October 10, 2026 08:59
@mvorisek

Copy link
Copy Markdown
Member

Thank you, great contibution!

@mvorisek

Copy link
Copy Markdown
Member

@DarkSide666 one question, what is your exact usecase?

@DarkSide666

Copy link
Copy Markdown
Member Author

I've hit it in one small internal app my colleague is developing and I was reviewing.
I guess 90% of time I use it to insert timestamp in DB without using php DateTime() and passing actual time to DB. Also for model default value for fields like created_at or in model hooks when you have to store precise time of event for example.

Thank you for your help! We both spent a lot of time on this :)

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants