Skip to content

Allow NULL in identities.organization on MySQL (#10148) - #10247

Open
MiMoHo wants to merge 1 commit into
roundcube:masterfrom
MiMoHo:fix-identities-organization-null-10148
Open

Allow NULL in identities.organization on MySQL (#10148)#10247
MiMoHo wants to merge 1 commit into
roundcube:masterfrom
MiMoHo:fix-identities-organization-null-10148

Conversation

@MiMoHo

@MiMoHo MiMoHo commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #10148

Problem

The identities.organization column allows NULL on PostgreSQL and SQLite, but is defined as NOT NULL DEFAULT '' on MySQL. As noted in #10148, the schemas should be unified.

An INSERT with an explicit NULL fails on MySQL (with the default strict SQL mode) with:

DB Error: [1048] Column 'organization' cannot be null

rcube_user::insert_identity() passes identity records through as-is, so a NULL organization supplied via the user_create/identity_create hooks (e.g. by the new_user_identity plugin when the LDAP attribute is absent) triggers this error and aborts the creation of new user accounts — which matches the reporter's observation that new accounts could not log in until the plugin was disabled.

Changes

  • SQL/mysql.initial.sql: organization varchar(128) NOT NULL DEFAULT ''organization varchar(128) DEFAULT NULL (matches the PostgreSQL definition)
  • New migration 2026070500.sql (MySQL: ALTER TABLE ... MODIFY; comment-only placeholder for PostgreSQL/SQLite, as in previous single-driver migrations)
  • Bumped the roundcube-version stamp in all three *.initial.sql files
  • CHANGELOG entry

Not touched (possible follow-up): reply-to and bcc have the same NULL-ability divergence between MySQL/SQLite and PostgreSQL, and SQLite keeps its DEFAULT '' for organization (changing a column default in SQLite would require a table rebuild, which seems disproportionate here since the NULL insert already works there).

Testing

Verified locally against MariaDB 12.3 (strict mode: STRICT_TRANS_TABLES,...) and SQLite; the MODIFY statement is elementary DDL and follows the same pattern already used for this very column in SQL/mysql/2011121400.sql:

  • Bug reproduction: applied the current (pre-change) mysql.initial.sql, inserted an identity with organization = NULL → fails with ERROR 1048 (23000): Column 'organization' cannot be null
  • Fresh install: applied the new mysql.initial.sql → column is NULL-able, NULL insert succeeds, version stamped 2026070500
  • Upgrade path: applied the old schema, ran bin/updatedb.sh --package=roundcube --dir=SQL → migration applies cleanly, NULL insert succeeds, version updated
  • Schema consistency: SHOW CREATE TABLE identities is identical between a fresh install and an upgraded install
  • SQLite upgrade path: comment-only migration applies cleanly via bin/updatedb.sh and bumps the stored version
  • Full PHPUnit suite passes (one pre-existing, unrelated local failure of RcubeTest::test_exec due to BSD vs GNU date on macOS)

This contribution was prepared with AI assistance (Claude Code); the analysis and all test results above were verified against a real database as described.

🤖 Generated with Claude Code

The PostgreSQL and SQLite schemas allow NULL in the
identities.organization column, but MySQL defined it as NOT NULL.
An INSERT with an explicit NULL - e.g. an identity record supplied
via the identity_create/user_create hooks by a plugin such as
new_user_identity with an LDAP lookup - fails on MySQL with:

    DB Error: [1048] Column 'organization' cannot be null

which in turn aborts the creation of new user accounts.

Unify the schemas by dropping the NOT NULL constraint on MySQL,
matching the PostgreSQL definition.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@MiMoHo
MiMoHo force-pushed the fix-identities-organization-null-10148 branch from f74d47f to 3ec4347 Compare July 19, 2026 02:26
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.

'organization' cannot be null

1 participant