rules

package
v1.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package rules contains individual dialect rewrite rules used by the transpiler.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MySQLAutoIncrementToSerial

func MySQLAutoIncrementToSerial(stmt ast.Statement) error

MySQLAutoIncrementToSerial rewrites columns that use the AUTO_INCREMENT constraint to use the PostgreSQL SERIAL (or BIGSERIAL) type instead.

MySQL: id INT AUTO_INCREMENT PRIMARY KEY PostgreSQL: id SERIAL PRIMARY KEY

func MySQLBacktickToDoubleQuote

func MySQLBacktickToDoubleQuote(_ ast.Statement) error

MySQLBacktickToDoubleQuote is a no-op: the GoSQLX tokenizer strips backtick quoting and stores raw identifier names in the AST. The formatter applies the correct quoting style for the target dialect.

func MySQLBooleanToPgBool

func MySQLBooleanToPgBool(stmt ast.Statement) error

MySQLBooleanToPgBool rewrites TINYINT columns (MySQL's conventional boolean representation) to BOOLEAN for PostgreSQL.

Only TINYINT with no explicit size argument or TINYINT(1) is rewritten.

MySQL: active TINYINT(1) or active TINYINT PostgreSQL: active BOOLEAN

func MySQLLimitCommaToOffset

func MySQLLimitCommaToOffset(_ ast.Statement) error

MySQLLimitCommaToOffset is a no-op: the GoSQLX parser already normalises MySQL's `LIMIT offset, count` syntax into the AST's Limit / Offset fields, which are emitted by the formatter in standard `LIMIT n OFFSET m` form.

func PgArrayToJSON

func PgArrayToJSON(stmt ast.Statement) error

PgArrayToJSON rewrites PostgreSQL array types (e.g. TEXT[], INT[]) to TEXT. SQLite has no native array type; storing JSON-encoded arrays as TEXT is the conventional workaround.

PostgreSQL: tags TEXT[] SQLite: tags TEXT

func PgDoubleQuoteToBacktick

func PgDoubleQuoteToBacktick(_ ast.Statement) error

PgDoubleQuoteToBacktick is a no-op: the GoSQLX AST stores raw (unquoted) identifier names. The formatter uses the target dialect's quoting style.

func PgILikeToLower

func PgILikeToLower(stmt ast.Statement) error

PgILikeToLower rewrites PostgreSQL ILIKE to a LOWER() … LIKE LOWER() pair that is compatible with MySQL.

PostgreSQL: col ILIKE '%alice%' MySQL: LOWER(col) LIKE LOWER('%alice%')

func PgSerialToAutoIncrement

func PgSerialToAutoIncrement(stmt ast.Statement) error

PgSerialToAutoIncrement rewrites PostgreSQL SERIAL / BIGSERIAL / SMALLSERIAL column types to the MySQL equivalent (INT / BIGINT with AUTO_INCREMENT).

PostgreSQL: id SERIAL PRIMARY KEY MySQL: id INT AUTO_INCREMENT PRIMARY KEY

func PgSerialToIntegerPK

func PgSerialToIntegerPK(stmt ast.Statement) error

PgSerialToIntegerPK rewrites PostgreSQL SERIAL/BIGSERIAL/SMALLSERIAL to INTEGER which, when paired with PRIMARY KEY, becomes SQLite's implicit auto-increment rowid alias.

PostgreSQL: id SERIAL PRIMARY KEY SQLite: id INTEGER PRIMARY KEY

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL