Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .github/workflows/compatibility.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ jobs:

- name: Build docker-compose services for integration tests (Linux only)
if: runner.os == 'Linux'
run: docker compose -f docker-compose.yml up -d
uses: Wandalen/wretry.action@v3.5.0
with:
attempt_limit: 5
attempt_delay: 5000
command: docker compose -f docker-compose.yml up -d
env:
MYSQL_VERSION: ${{ matrix.db.mysql }}
PG_VERSION: ${{ matrix.db.postgres }}
Expand Down Expand Up @@ -212,7 +216,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: 5
attempt_delay: 5000
command: docker compose -f docker-compose.yml up -d
env:
MYSQL_VERSION: ${{ matrix.db.mysql }}
PG_VERSION: ${{ matrix.db.postgres }}
Expand Down
2 changes: 1 addition & 1 deletion src/ts_generator/types/ts_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
32 changes: 32 additions & 0 deletions tests/demo/mysql/set_insert.queries.ts
Original file line number Diff line number Diff line change
@@ -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;
}
33 changes: 33 additions & 0 deletions tests/demo/mysql/set_insert.snapshot.ts
Original file line number Diff line number Diff line change
@@ -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;
}

29 changes: 29 additions & 0 deletions tests/demo/mysql/set_insert.ts
Original file line number Diff line number Diff line change
@@ -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
(?),
(?)
`
34 changes: 34 additions & 0 deletions tests/demo/mysql/set_select.queries.ts
Original file line number Diff line number Diff line change
@@ -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;
}
35 changes: 35 additions & 0 deletions tests/demo/mysql/set_select.snapshot.ts
Original file line number Diff line number Diff line change
@@ -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;
}

32 changes: 32 additions & 0 deletions tests/demo/mysql/set_select.ts
Original file line number Diff line number Diff line change
@@ -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 = ?
`
Loading