Skip to content

Multi-Dialect Support

Relayer detects the SQL dialect from your Drizzle schema (by checking whether your tables are PgTable, MySqlTable, or SQLiteTable) and adjusts SQL generation automatically.

Dialect comparison

FeaturePostgreSQLMySQLSQLite
ilikeNative ILIKELOWER(col) LIKE LOWER(val)col LIKE val COLLATE NOCASE
notIlikeNative NOT ILIKELOWER(col) NOT LIKE LOWER(val)col NOT LIKE val COLLATE NOCASE
Array operatorsNative (@>, <@, &&)Not supportedNot supported
JSON pathcol->>'key' with ::castcol->>'$.key' with CAST()json_extract(col, '$.key') with CAST()
Nested JSONcol->'a'->>'b'col->>'$.a.b'json_extract(col, '$.a.b')
Numeric JSON cast::numericCAST(... AS DECIMAL)CAST(... AS REAL)
Boolean JSON cast::booleanCAST(... AS UNSIGNED)CAST(... AS INTEGER)
RETURNINGYesNo (insertId fallback)Yes

Usage with PostgreSQL

import { pgTable, serial, text } from 'drizzle-orm/pg-core';
const users = pgTable('users', {
id: serial('id').primaryKey(),
name: text('name').notNull(),
});

PostgreSQL gets the most complete feature set: native ILIKE, array operators, JSONB with optimized path queries, and RETURNING for mutations.

Usage with MySQL

import { mysqlTable, serial, varchar } from 'drizzle-orm/mysql-core';
const users = mysqlTable('users', {
id: serial('id').primaryKey(),
name: varchar('name', { length: 255 }).notNull(),
});

MySQL uses fallback implementations for ilike (LOWER wrapping) and does not support array operators. RETURNING is not available — create uses insertId to fetch the created row.

Usage with SQLite

import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core';
const users = sqliteTable('users', {
id: integer('id').primaryKey({ autoIncrement: true }),
name: text('name').notNull(),
});

SQLite uses COLLATE NOCASE for case-insensitive matching and json_extract() for JSON paths. Array operators are not supported. RETURNING is available.

Array operators

Array operators (arrayContains, arrayContained, arrayOverlaps) are PostgreSQL-only features that use native PG array operations:

// Only works with PostgreSQL schemas
await r.posts.findMany({
where: { tags: { arrayContains: ['typescript'] } },
});

Writing dialect-agnostic code

If you need to support multiple dialects, avoid:

  • Array operators (arrayContains, arrayContained, arrayOverlaps)
  • Relying on MySQL-specific insertId behavior

Everything else (JSON filtering, ilike, computed fields, derived fields, relations, aggregations) works consistently across all three dialects.