Skip to content

@prisma/adapter-mariadb: supportsRelationJoins version check fails for MySQL >= 8.1 #29235

@aaronjwhiteside-appdirect

Description

Bug description

The inferCapabilities function in @prisma/adapter-mariadb has a broken semver comparison that causes supportsRelationJoins to incorrectly evaluate to false for MySQL versions >= 8.1.0 where the patch version is less than 13.

This forces Prisma to fall back to multi-query relation loading (separate SQL statements wrapped in BEGIN/COMMIT) instead of using lateral JOINs, resulting in unnecessary performance overhead.

Location

@prisma/adapter-mariadb/dist/index.mjsinferCapabilities():

function inferCapabilities(version) {
  if (typeof version !== "string") {
    return { supportsRelationJoins: false };
  }
  const [versionStr, suffix] = version.split("-");
  const [major, minor, patch] = versionStr.split(".").map((n) => parseInt(n, 10));
  const isMariaDB = suffix?.toLowerCase()?.includes("mariadb") ?? false;
  const supportsRelationJoins = !isMariaDB && (major > 8 || major === 8 && minor >= 0 && patch >= 13);
  return { supportsRelationJoins };
}

The condition major === 8 && minor >= 0 && patch >= 13 checks the patch version independently of the minor version. This means any MySQL 8.x.y version where y < 13 fails the check, even if x > 0 (which implies a version newer than 8.0.13).

Examples

MySQL Version VERSION() string Expected Actual Correct?
8.0.12 "8.0.12" false false Yes
8.0.13 "8.0.13" true true Yes
8.0.32 "8.0.32" true true Yes
8.1.0 "8.1.0" true false No
8.2.0 "8.2.0" true false No
8.3.0 "8.3.0" true false No
8.4.0 "8.4.0" true false No
8.4.5 "8.4.5" true false No
8.4.13 "8.4.13" true true Yes (by accident)
9.0.0 "9.0.0" true true Yes
9.1.0 "9.1.0" true true Yes
10.11.6-MariaDB "10.11.6-MariaDB" false false Yes

All MySQL versions from 8.1.0 through 8.x.12 (where x >= 1) are incorrectly treated as not supporting relation JOINs. This covers the current MySQL 8.4 LTS and Innovation releases 8.1, 8.2, and 8.3.

Suggested fix

Replace the flat && comparison with a proper semver-aware check:

const supportsRelationJoins = !isMariaDB && (
  major > 8 ||
  (major === 8 && (minor > 0 || (minor === 0 && patch >= 13)))
);

This correctly treats any MySQL 8.1+ as newer than 8.0.13.

Impact

When supportsRelationJoins is incorrectly false, Prisma:

  1. Falls back to separate SQL queries for relation loading instead of using lateral JOINs
  2. Wraps those multi-query operations in implicit transactions (BEGIN / SELECT / SELECT / COMMIT), adding 3+ round-trips per query instead of 1
  3. Effectively prevents parallel execution of concurrent Prisma queries (via Promise.all) because each query's implicit transaction occupies a connection for longer and adds synchronous overhead between queries

Environment

  • @prisma/adapter-mariadb: 7.4.1 (also verified in 7.5.0)
  • MySQL: 8.1.0, 8.4.0 (affected)
  • MySQL: 8.0.32 (not affected)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug/1-unconfirmedBug should have enough information for reproduction, but confirmation has not happened yet.kind/bugA reported bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions