Minor Changes
- Query builder results now read
boolean()columns astrueorfalse. MySQL stores booleans astinyint(1), which mysql2 returns as1or0.db.exec()results keep the values mysql2 returns. (#12337)
Patch Changes
-
Bind every query parameter as exactly one value. Previously, mysql2 expanded array parameters into lists and plain-object parameters into column assignments, and it substituted values into question marks inside quoted strings, quoted identifiers, and comments. The adapter now binds parameters itself: it rejects objects other than
Date,Buffer, typed arrays, andDataView(including mysql2raw()andtoSqlString()objects, which mysql2 inlined as SQL), binds bigints as integers instead of quoted strings, rejectsNaNandInfinity, leaves question marks inside quotes and comments as written, and rejects statements whose placeholder and value counts differ. (#12335)Raw SQL that relied on mysql2's array expansion, object expansion, or
??identifier placeholder must be rewritten. UseJSON.stringify(value)for JSON data,inList()or one placeholder per item for lists of values, and quoted identifiers in the SQL text.-await db.exec('select * from accounts where id in (?)', [[1, 2]]) +await db.exec('select * from accounts where id in (?, ?)', [1, 2]) -await db.exec('select ?? from accounts', ['email']) +await db.exec('select `email` from accounts')
-
Fix upserts with a separate
updateobject binding values in the wrong order. Compiled statements bound theon duplicate key updatevalues before the inserted values, so an upsert such asupsert({ status: 'enabled', email: 'info@remix.run' }, { update: { email: 'contact@remix.run' } })wrote the update value into the first inserted column. Inserted values are now bound first, matching their placeholders. (#12276) -
Bumped
@remix-run/*dependencies: