How to Fix MySQL Error 3105 (ER_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN)
You get mysql error 3105 when a query writes a custom value into a generated column. Fix it by omitting that column from your query or sending the default keyword instead. MySQL builds generated columns from an expression saved in the table schema. The database engine computes these values on the fly or on write. It rejects any manual data sent to these fields. When an app or script sends a literal value, the server stops the write right away. This rule keeps your computed data in sync with the
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You get mysql error 3105 when a query writes a custom value into a generated column. Fix it by omitting that column from your query or sending the default keyword instead.
MySQL builds generated columns from an expression saved in the table schema. The database engine computes these values on the fly or on write. It rejects any manual data sent to these fields. When an app or script sends a literal value, the server stops the write right away. This rule keeps your computed data in sync with the source columns in the table.
What causes mysql error 3105 in the database
The database server tracks this issue under the symbol ER_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN and SQLSTATE HY000. The server returns a clear message when a query breaks this rule. It says the value specified for the generated column in the table is not allowed. Both virtual and stored generated columns trigger this exact error code.
Most failures happen during insert or update queries that do not list target column names. If an insert statement skips the column list, it must supply a value for every field. When the value list includes a number or string for the generated slot, the query fails. You must pass the default keyword in that slot if you omit the column list.
Object-relational mappers and data sync scripts also cause this error after a schema change. A team might convert a standard column into a generated column during a migration. If the app model still marks that field as writable, it will send values during saves. Bulk data imports from older backups can fail for the same reason.
How to diagnose and fix the failure in production
Start your check by reading the exact error message in your app logs. The message names both the generated column and the target table. Next, inspect the table schema in your database to see how that column works. Check which base columns feed the formula for the generated field.
Do not relax SQL modes or grant broad schema rights to bypass this check. Turning off strict checks can corrupt data across other tables in your database. Instead, fix the write query in your app code or migration script. Remove the generated column name from the insert or update field list.
Non-Human Identity Management + MySQL Access Governance: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
If your app updates the data, change the base columns that feed the formula. The engine will recalculate the generated field on its own during the write. If you use an object-relational mapper, mark the field as read-only in your model. This stops the app from including the column in future write queries.
How to prevent generated column write errors
You can stop this error before it reaches production by checking schema changes early. When you add a generated column, search your codebase for all writes to that table. Replace any wildcard insert statements with explicit column lists in your queries. Explicit lists make your queries safe when someone adds new generated columns later.
Test your data import scripts against a staging database that matches your production schema. If a backup tool exports data from generated columns, set it to skip those fields. Good database access controls also help your team catch bad manual queries before they run. Reviewing ad-hoc production updates keeps operators from writing to computed fields by mistake.
Inspect every MySQL query and response in flight
Static grants and network rules block bad logins. They cannot pause a risky query for review or mask emails in a result set. By design, hoop.dev sits inline in the MySQL protocol as a sidecar for your MySQL. For every plain query, prepared statement, or cursor an agent or human runs in production, hoop.dev decides to pass, mask, block, or hold it for review.
First, hoop.dev guardrails block banned actions before MySQL runs them, and an AI Analyzer you configure can score intent or escalate for approval. Next, hoop.dev data masking rewrites sensitive string columns in results in memory, and every verdict goes to the audit trail. Find the open-source binary on GitHub.
Frequently asked questions
Can I insert NULL into a MySQL generated column?
No, sending NULL triggers error 3105 because NULL counts as a specified value. You must either omit the column from the query or pass the default keyword.
Does mysql error 3105 affect both virtual and stored columns?
Yes, the database blocks manual writes to both virtual and stored generated columns. The engine always calculates the value from the expression defined in the table schema.
How do I update the value inside a generated column?
You update a generated column by changing the base columns referenced in its expression. If the formula itself is wrong, an admin must alter the table definition.
Related guides
In this post