Skip to content

Clarify DEFAULT_GENERATED vs ON UPDATE distinction with test coverage#31

Closed
Copilot wants to merge 4 commits intomainfrom
copilot/sub-pr-30
Closed

Clarify DEFAULT_GENERATED vs ON UPDATE distinction with test coverage#31
Copilot wants to merge 4 commits intomainfrom
copilot/sub-pr-30

Conversation

Copy link

Copilot AI commented Feb 19, 2026

In response to feedback questioning why DEFAULT_GENERATED shouldn't be treated as a computed column alongside ON UPDATE CURRENT_TIMESTAMP.

Key Distinction

MySQL's EXTRA column contains separate indicators:

  • DEFAULT_GENERATED (from DEFAULT CURRENT_TIMESTAMP) - provides a default value but can be overridden during INSERT
  • ON UPDATE CURRENT_TIMESTAMP - automatically updates on every UPDATE regardless of user input

Only the latter exhibits true computed/read-only behavior.

Changes

  • Test coverage: Added TimestampComputedColumnTests.cs demonstrating:
    • Explicit override capability of DEFAULT CURRENT_TIMESTAMP columns during INSERT
    • Automatic update behavior of ON UPDATE CURRENT_TIMESTAMP columns
    • Current implementation correctly marks only ON UPDATE columns as IsGenerated

Example test table structure:

CREATE TABLE TimestampTestTable (
    CreatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,              -- IsGenerated = false
    UpdatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,  -- IsGenerated = true
    OnUpdateOnly TIMESTAMP NULL ON UPDATE CURRENT_TIMESTAMP     -- IsGenerated = true
)

Treating DEFAULT_GENERATED as computed would incorrectly prevent applications from specifying explicit timestamps during inserts.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix handling default as separate bit in MySQL computed columns Clarify DEFAULT_GENERATED vs ON UPDATE distinction with test coverage Feb 19, 2026
Copilot AI requested a review from rhuijben February 19, 2026 09:10
@rhuijben rhuijben force-pushed the fix/mysql-on-update-computed branch from 500bca7 to 1cd0ca9 Compare February 19, 2026 09:12
Copilot AI and others added 3 commits February 19, 2026 10:31
…tion

Co-authored-by: rhuijben <2271549+rhuijben@users.noreply.github.com>
Co-authored-by: rhuijben <2271549+rhuijben@users.noreply.github.com>
Base automatically changed from fix/mysql-on-update-computed to main February 20, 2026 14:53
@rhuijben rhuijben marked this pull request as ready for review February 20, 2026 16:20
@rhuijben
Copy link
Member

Code integrated via other pr.

@rhuijben rhuijben closed this Feb 23, 2026
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