Skip to content

Enable STRICT_TRANS_TABLES: audit and fix INSERT/UPDATE paths #487

Description

@Neophytis

Context

The beta stack runs MariaDB 12, which enables STRICT_TRANS_TABLES by default. The application was built against Lion's MariaDB which had no strict mode, so many write paths silently rely on non-strict behaviour. With strict mode on, the following break:

  • Gallery image uploads
  • Sending messages
  • Forum post submission
  • Any INSERT/UPDATE hitting a NOT NULL column without a default value, a string longer than its column definition, or an invalid date literal

Current decision: STRICT_TRANS_TABLES is explicitly excluded from sql_mode in the beta DB config to match Lion's historical behaviour and unblock the migration:

sql_mode = NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

This is tracked in sysadmins-infra hosts/bewelcome_alpha/compose/bewelcome/mariadb-tuning.cnf.

What needs fixing before re-enabling strict mode

  1. Missing defaults — find NOT NULL columns that have no DEFAULT and ensure the application always provides a value on INSERT.
  2. Silent string truncation — find VARCHAR/TINYTEXT columns where the application may insert a value longer than the column definition.
  3. Invalid datetime literals0000-00-00 dates in queries or inserts must be replaced with NULL or a valid date.
  4. Implicit integer coercion — out-of-range values on TINYINT/SMALLINT columns that were silently clamped.

How to find them

Run the application manually on beta with strict mode temporarily re-enabled and collect the resulting SQL errors from the slow query log or application logs. Each error points to a specific query.

Definition of done

All functional tests pass with sql_mode = STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION. At that point the override in sysadmins-infra can be removed.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    improvementrecodeThis label is used when an issue is related to a re-coding task.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions