From 39e6298fab47d1a33287bcb1b64cc9a5223dfbc7 Mon Sep 17 00:00:00 2001 From: Jareth Gomes Date: Sat, 21 Feb 2026 22:19:44 -0800 Subject: [PATCH 1/6] Add MySQL `SET` type support Adds `SET` to be represented as a `string` in Typescript since MySQL returns back a comma delimited string, and typescript expects a comma delimited string for update/insertion. --- src/ts_generator/types/ts_query.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ts_generator/types/ts_query.rs b/src/ts_generator/types/ts_query.rs index a6e72c9e..02f0e56d 100644 --- a/src/ts_generator/types/ts_query.rs +++ b/src/ts_generator/types/ts_query.rs @@ -223,7 +223,7 @@ impl TsFieldType { ) -> Self { match mysql_field_type.as_str() { "bigint" | "decimal" | "double" | "float" | "int" | "mediumint" | "smallint" | "year" => Self::Number, - "binary" | "bit" | "blob" | "char" | "text" | "varbinary" | "varchar" => Self::String, + "binary" | "bit" | "blob" | "char" | "text" | "varbinary" | "varchar" | "set" => Self::String, "tinyint" => Self::Boolean, "date" | "datetime" | "timestamp" => Self::Date, "json" => Self::Object, From 11e3c6589ba130ca461666859210212724fa9b50 Mon Sep 17 00:00:00 2001 From: Jareth Gomes Date: Sun, 22 Feb 2026 16:19:38 -0800 Subject: [PATCH 2/6] Add tests for `SET` type generation --- tests/mysql_sets.rs | 67 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 tests/mysql_sets.rs diff --git a/tests/mysql_sets.rs b/tests/mysql_sets.rs new file mode 100644 index 00000000..d4c0c611 --- /dev/null +++ b/tests/mysql_sets.rs @@ -0,0 +1,67 @@ +#[cfg(test)] +mod sets { + use assert_cmd::prelude::*; + use pretty_assertions::assert_eq; + use std::env; + use std::fs; + use std::io::Write; + use std::process::Command; + use tempfile::tempdir; + + use test_utils::test_utils::TSString; + use test_utils::{run_test, sandbox::TestConfig}; + + #[rustfmt::skip] +run_test!(should_generate_sets_for_mysql, TestConfig::new("mysql", true, None, None), + +//// TS query //// +r#" +const setQuery = sql` + SELECT + set1 + FROM + random +`; +"#, + +//// Generated TS interfaces //// +r#" +export type SetQueryParams = []; + +export interface ISetQueryResult { + set1: string | null; +} + +export interface ISetQueryQuery { + params: SetQueryParams; + result: ISetQueryResult; +} +"#); + + #[rustfmt::skip] +run_test!(should_generate_set_insert_params_for_mysql, TestConfig::new("mysql", true, None, None), + +//// TS query //// +r#" +const setQuery = sql` + INSERT INTO + random (set1) + VALUES + (?) +`; +"#, + +//// Generated TS interfaces //// +r#" +export type SetQueryParams = [[string | null]]; + +export interface ISetQueryResult { + +} + +export interface ISetQueryQuery { + params: SetQueryParams; + result: ISetQueryResult; +} +"#); +} From 748bedbb2d0a36dac46dbbeeab9d8a4d17c5218e Mon Sep 17 00:00:00 2001 From: JasonShin Date: Tue, 10 Mar 2026 21:56:21 +1100 Subject: [PATCH 3/6] organise tests --- tests/demo/mysql/set_insert.queries.ts | 32 ++++++++++++ tests/demo/mysql/set_insert.snapshot.ts | 33 ++++++++++++ tests/demo/mysql/set_insert.ts | 29 +++++++++++ tests/demo/mysql/set_select.queries.ts | 34 +++++++++++++ tests/demo/mysql/set_select.snapshot.ts | 35 +++++++++++++ tests/demo/mysql/set_select.ts | 32 ++++++++++++ tests/mysql_sets.rs | 67 ------------------------- 7 files changed, 195 insertions(+), 67 deletions(-) create mode 100644 tests/demo/mysql/set_insert.queries.ts create mode 100644 tests/demo/mysql/set_insert.snapshot.ts create mode 100644 tests/demo/mysql/set_insert.ts create mode 100644 tests/demo/mysql/set_select.queries.ts create mode 100644 tests/demo/mysql/set_select.snapshot.ts create mode 100644 tests/demo/mysql/set_select.ts delete mode 100644 tests/mysql_sets.rs diff --git a/tests/demo/mysql/set_insert.queries.ts b/tests/demo/mysql/set_insert.queries.ts new file mode 100644 index 00000000..b7f9d7f9 --- /dev/null +++ b/tests/demo/mysql/set_insert.queries.ts @@ -0,0 +1,32 @@ +export type SetInsert1Params = [[string | null]]; + +export interface ISetInsert1Result { + +} + +export interface ISetInsert1Query { + params: SetInsert1Params; + result: ISetInsert1Result; +} + +export type SetInsert2Params = [[number | null, string | null, string | null]]; + +export interface ISetInsert2Result { + +} + +export interface ISetInsert2Query { + params: SetInsert2Params; + result: ISetInsert2Result; +} + +export type SetInsert3Params = [[string | null], [string | null]]; + +export interface ISetInsert3Result { + +} + +export interface ISetInsert3Query { + params: SetInsert3Params; + result: ISetInsert3Result; +} diff --git a/tests/demo/mysql/set_insert.snapshot.ts b/tests/demo/mysql/set_insert.snapshot.ts new file mode 100644 index 00000000..62530bb1 --- /dev/null +++ b/tests/demo/mysql/set_insert.snapshot.ts @@ -0,0 +1,33 @@ +export type SetInsert1Params = [[string | null]]; + +export interface ISetInsert1Result { + +} + +export interface ISetInsert1Query { + params: SetInsert1Params; + result: ISetInsert1Result; +} + +export type SetInsert2Params = [[number | null, string | null, string | null]]; + +export interface ISetInsert2Result { + +} + +export interface ISetInsert2Query { + params: SetInsert2Params; + result: ISetInsert2Result; +} + +export type SetInsert3Params = [[string | null], [string | null]]; + +export interface ISetInsert3Result { + +} + +export interface ISetInsert3Query { + params: SetInsert3Params; + result: ISetInsert3Result; +} + diff --git a/tests/demo/mysql/set_insert.ts b/tests/demo/mysql/set_insert.ts new file mode 100644 index 00000000..a63bb2b8 --- /dev/null +++ b/tests/demo/mysql/set_insert.ts @@ -0,0 +1,29 @@ +import { sql } from 'sqlx-ts' + +// MySQL SET type - insert single value +const setInsert1 = sql` +-- @db: db_mysql +INSERT INTO + random (set1) +VALUES + (?) +` + +// MySQL SET type - insert multiple columns including SET +const setInsert2 = sql` +-- @db: db_mysql +INSERT INTO + random (intz, set1, varchar1) +VALUES + (?, ?, ?) +` + +// MySQL SET type - insert with multiple rows +const setInsert3 = sql` +-- @db: db_mysql +INSERT INTO + random (set1) +VALUES + (?), + (?) +` diff --git a/tests/demo/mysql/set_select.queries.ts b/tests/demo/mysql/set_select.queries.ts new file mode 100644 index 00000000..2e74237d --- /dev/null +++ b/tests/demo/mysql/set_select.queries.ts @@ -0,0 +1,34 @@ +export type SetSelect1Params = []; + +export interface ISetSelect1Result { + set1: string | null; +} + +export interface ISetSelect1Query { + params: SetSelect1Params; + result: ISetSelect1Result; +} + +export type SetSelect2Params = []; + +export interface ISetSelect2Result { + intz: number | null; + set1: string | null; + varchar1: string | null; +} + +export interface ISetSelect2Query { + params: SetSelect2Params; + result: ISetSelect2Result; +} + +export type SetSelect3Params = [number | null]; + +export interface ISetSelect3Result { + set1: string | null; +} + +export interface ISetSelect3Query { + params: SetSelect3Params; + result: ISetSelect3Result; +} diff --git a/tests/demo/mysql/set_select.snapshot.ts b/tests/demo/mysql/set_select.snapshot.ts new file mode 100644 index 00000000..d5ec90c6 --- /dev/null +++ b/tests/demo/mysql/set_select.snapshot.ts @@ -0,0 +1,35 @@ +export type SetSelect1Params = []; + +export interface ISetSelect1Result { + set1: string | null; +} + +export interface ISetSelect1Query { + params: SetSelect1Params; + result: ISetSelect1Result; +} + +export type SetSelect2Params = []; + +export interface ISetSelect2Result { + intz: number | null; + set1: string | null; + varchar1: string | null; +} + +export interface ISetSelect2Query { + params: SetSelect2Params; + result: ISetSelect2Result; +} + +export type SetSelect3Params = [number | null]; + +export interface ISetSelect3Result { + set1: string | null; +} + +export interface ISetSelect3Query { + params: SetSelect3Params; + result: ISetSelect3Result; +} + diff --git a/tests/demo/mysql/set_select.ts b/tests/demo/mysql/set_select.ts new file mode 100644 index 00000000..39107aa1 --- /dev/null +++ b/tests/demo/mysql/set_select.ts @@ -0,0 +1,32 @@ +import { sql } from 'sqlx-ts' + +// MySQL SET type - select single SET column +const setSelect1 = sql` +-- @db: db_mysql +SELECT + set1 +FROM + random +` + +// MySQL SET type - select multiple columns including SET +const setSelect2 = sql` +-- @db: db_mysql +SELECT + intz, + set1, + varchar1 +FROM + random +` + +// MySQL SET type - with WHERE clause +const setSelect3 = sql` +-- @db: db_mysql +SELECT + set1 +FROM + random +WHERE + intz = ? +` diff --git a/tests/mysql_sets.rs b/tests/mysql_sets.rs deleted file mode 100644 index d4c0c611..00000000 --- a/tests/mysql_sets.rs +++ /dev/null @@ -1,67 +0,0 @@ -#[cfg(test)] -mod sets { - use assert_cmd::prelude::*; - use pretty_assertions::assert_eq; - use std::env; - use std::fs; - use std::io::Write; - use std::process::Command; - use tempfile::tempdir; - - use test_utils::test_utils::TSString; - use test_utils::{run_test, sandbox::TestConfig}; - - #[rustfmt::skip] -run_test!(should_generate_sets_for_mysql, TestConfig::new("mysql", true, None, None), - -//// TS query //// -r#" -const setQuery = sql` - SELECT - set1 - FROM - random -`; -"#, - -//// Generated TS interfaces //// -r#" -export type SetQueryParams = []; - -export interface ISetQueryResult { - set1: string | null; -} - -export interface ISetQueryQuery { - params: SetQueryParams; - result: ISetQueryResult; -} -"#); - - #[rustfmt::skip] -run_test!(should_generate_set_insert_params_for_mysql, TestConfig::new("mysql", true, None, None), - -//// TS query //// -r#" -const setQuery = sql` - INSERT INTO - random (set1) - VALUES - (?) -`; -"#, - -//// Generated TS interfaces //// -r#" -export type SetQueryParams = [[string | null]]; - -export interface ISetQueryResult { - -} - -export interface ISetQueryQuery { - params: SetQueryParams; - result: ISetQueryResult; -} -"#); -} From 41da114d51ce9df5ee6f1db313cdc4054a1cd4e9 Mon Sep 17 00:00:00 2001 From: JasonShin Date: Tue, 10 Mar 2026 22:09:21 +1100 Subject: [PATCH 4/6] compatiblity.yaml retry --- .github/workflows/compatibility.yaml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/compatibility.yaml b/.github/workflows/compatibility.yaml index 83a75cc0..86906deb 100644 --- a/.github/workflows/compatibility.yaml +++ b/.github/workflows/compatibility.yaml @@ -71,9 +71,12 @@ jobs: with: node-version: '20' - - name: Build docker-compose services for integration tests (Linux only) - if: runner.os == 'Linux' - run: docker compose -f docker-compose.yml up -d + - name: Build docker-compose services + uses: Wandalen/wretry.action@v3.5.0 + with: + attempt_limit: 3 + attempt_delay: 5000 + command: docker compose -f docker-compose.yml up -d env: MYSQL_VERSION: ${{ matrix.db.mysql }} PG_VERSION: ${{ matrix.db.postgres }} @@ -212,7 +215,11 @@ jobs: uses: actions/checkout@v3 - name: Build docker-compose services - run: docker compose -f docker-compose.yml up -d + uses: Wandalen/wretry.action@v3.5.0 + with: + attempt_limit: 3 + attempt_delay: 5000 + command: docker compose -f docker-compose.yml up -d env: MYSQL_VERSION: ${{ matrix.db.mysql }} PG_VERSION: ${{ matrix.db.postgres }} From 9eb9e9ac58cbc8bfe9686367398d900b092d999f Mon Sep 17 00:00:00 2001 From: JasonShin Date: Tue, 10 Mar 2026 22:11:11 +1100 Subject: [PATCH 5/6] try 5 --- .github/workflows/compatibility.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/compatibility.yaml b/.github/workflows/compatibility.yaml index 86906deb..38529e12 100644 --- a/.github/workflows/compatibility.yaml +++ b/.github/workflows/compatibility.yaml @@ -74,7 +74,7 @@ jobs: - name: Build docker-compose services uses: Wandalen/wretry.action@v3.5.0 with: - attempt_limit: 3 + attempt_limit: 5 attempt_delay: 5000 command: docker compose -f docker-compose.yml up -d env: @@ -217,7 +217,7 @@ jobs: - name: Build docker-compose services uses: Wandalen/wretry.action@v3.5.0 with: - attempt_limit: 3 + attempt_limit: 5 attempt_delay: 5000 command: docker compose -f docker-compose.yml up -d env: From 10535b5b51207f1fde4dd888656f46a2b651bab6 Mon Sep 17 00:00:00 2001 From: JasonShin Date: Tue, 10 Mar 2026 22:17:19 +1100 Subject: [PATCH 6/6] linux only --- .github/workflows/compatibility.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/compatibility.yaml b/.github/workflows/compatibility.yaml index 38529e12..57ee191e 100644 --- a/.github/workflows/compatibility.yaml +++ b/.github/workflows/compatibility.yaml @@ -71,7 +71,8 @@ jobs: with: node-version: '20' - - name: Build docker-compose services + - name: Build docker-compose services for integration tests (Linux only) + if: runner.os == 'Linux' uses: Wandalen/wretry.action@v3.5.0 with: attempt_limit: 5