Bug #107530 GENERATED STORED fields can't be omitted from INSERT?
Submitted: 9 Jun 2022 18:37 Modified: 10 Jun 2022 11:57
Reporter: Nino Skopac Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:8.0.28 OS:Any
Assigned to: CPU Architecture:Any

[9 Jun 2022 18:37] Nino Skopac
Description:
Why can't date and hour fields be omitted?

Thank you

How to repeat:
create table raw (
	`dt` datetime default current_timestamp,
	`date` date GENERATED ALWAYS AS (cast(`dt` as date)) STORED NOT NULL,
	`hour` tinyint unsigned GENERATED ALWAYS AS (hour(`dt`)) STORED NOT NULL,
	`data` json DEFAULT NULL,
	PRIMARY KEY (`date`,`hour`)
);
Query 1 OK: 0 rows affected

---
insert into raw(data) values(json_array())
Query 1 ERROR: Column 'date' cannot be null
[10 Jun 2022 11:57] MySQL Verification Team
Hi Mr. Skopac,

Thank you very much for your bug report.

However, this is not a bug, but intended behaviour.

Those columns can not be NULL simply because they are generated from the column that is never NULL.

Not a bug.