Skip to content

Commit 71f0eff

Browse files
committed
Realse 0.3.1 - fix double processing stmts when processing expr callees
1 parent c5dfd41 commit 71f0eff

File tree

7 files changed

+50
-87
lines changed

7 files changed

+50
-87
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "sqlx-ts"
3-
version = "0.3.0"
3+
version = "0.3.1"
44
edition = "2021"
55
homepage = "https://github.com/JasonShin/sqlx-ts"
66
authors = ['Jason Shin <[email protected]>']

node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sqlx-ts",
3-
"version": "0.3.0",
3+
"version": "0.3.1",
44
"description": "sqlx-ts ensures your raw SQLs are compile-time checked",
55
"main": "dist/index.js",
66
"maintainers": [

src/parser/tag.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ pub fn process_block_stmt_as_expr(
2020
if let Some(expr) = expr {
2121
let expr = &expr.expr;
2222
get_sql_from_expr(sqls, var_decl_name, expr, span, import_alias);
23+
} else {
24+
recurse_and_find_sql(sqls, stmt, import_alias);
2325
}
24-
25-
let _ = recurse_and_find_sql(sqls, stmt, import_alias);
2626
}
2727
}
2828
}
@@ -67,7 +67,6 @@ pub fn get_sql_from_expr<'a>(
6767
span: span.clone(),
6868
})
6969
.collect();
70-
7170
sqls.extend(new_sqls.clone());
7271
}
7372
}
@@ -76,8 +75,12 @@ pub fn get_sql_from_expr<'a>(
7675
get_sql_from_expr(sqls, var_decl_name, &expr.expr, span, import_alias);
7776
}
7877
Expr::Call(call_expr) => {
78+
let num_args = &call_expr.args.len();
79+
7980
if let Some(callee_expr) = &call_expr.callee.as_expr() {
80-
get_sql_from_expr(sqls, var_decl_name, callee_expr, span, import_alias);
81+
if num_args == &0 {
82+
get_sql_from_expr(sqls, var_decl_name, callee_expr, span, import_alias);
83+
}
8184
}
8285
for arg in &call_expr.args {
8386
get_sql_from_expr(sqls, var_decl_name, &arg.expr, span, import_alias)

tests/demo/ts-syntax/ts-syntax.queries.ts

Lines changed: 16 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -770,46 +770,6 @@ export interface ITestAwaitQueryQuery {
770770

771771

772772

773-
export type TestAwaitQueryParams = [];
774-
775-
776-
export interface ITestAwaitQueryResult {
777-
food_type: string;
778-
id: number;
779-
points: number;
780-
table_id: number;
781-
time_takes_to_cook: number;
782-
};
783-
784-
785-
export interface ITestAwaitQueryQuery {
786-
params: TestAwaitQueryParams;
787-
result: ITestAwaitQueryResult;
788-
};
789-
790-
791-
792-
793-
export type TestAwaitQuery2Params = [];
794-
795-
796-
export interface ITestAwaitQuery2Result {
797-
food_type: string;
798-
id: number;
799-
points: number;
800-
table_id: number;
801-
time_takes_to_cook: number;
802-
};
803-
804-
805-
export interface ITestAwaitQuery2Query {
806-
params: TestAwaitQuery2Params;
807-
result: ITestAwaitQuery2Result;
808-
};
809-
810-
811-
812-
813773
export type TestAwaitQuery2Params = [];
814774

815775

@@ -867,3 +827,19 @@ export interface IGetItemsWithRowsQuery {
867827
result: IGetItemsWithRowsResult;
868828
};
869829

830+
831+
832+
833+
export type TestInsertParams = [[string, number]];
834+
835+
836+
export interface ITestInsertResult {
837+
838+
};
839+
840+
841+
export interface ITestInsertQuery {
842+
params: TestInsertParams;
843+
result: ITestInsertResult;
844+
};
845+

tests/demo/ts-syntax/ts-syntax.snapshot.ts

Lines changed: 16 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -770,46 +770,6 @@ export interface ITestAwaitQueryQuery {
770770

771771

772772

773-
export type TestAwaitQueryParams = [];
774-
775-
776-
export interface ITestAwaitQueryResult {
777-
food_type: string;
778-
id: number;
779-
points: number;
780-
table_id: number;
781-
time_takes_to_cook: number;
782-
};
783-
784-
785-
export interface ITestAwaitQueryQuery {
786-
params: TestAwaitQueryParams;
787-
result: ITestAwaitQueryResult;
788-
};
789-
790-
791-
792-
793-
export type TestAwaitQuery2Params = [];
794-
795-
796-
export interface ITestAwaitQuery2Result {
797-
food_type: string;
798-
id: number;
799-
points: number;
800-
table_id: number;
801-
time_takes_to_cook: number;
802-
};
803-
804-
805-
export interface ITestAwaitQuery2Query {
806-
params: TestAwaitQuery2Params;
807-
result: ITestAwaitQuery2Result;
808-
};
809-
810-
811-
812-
813773
export type TestAwaitQuery2Params = [];
814774

815775

@@ -868,3 +828,19 @@ export interface IGetItemsWithRowsQuery {
868828
};
869829

870830

831+
832+
833+
export type TestInsertParams = [[string, number]];
834+
835+
836+
export interface ITestInsertResult {
837+
838+
};
839+
840+
841+
export interface ITestInsertQuery {
842+
params: TestInsertParams;
843+
result: ITestInsertResult;
844+
};
845+
846+

tests/demo/ts-syntax/ts-syntax.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,4 +302,12 @@ function *yieldMethod() {
302302
SELECT * FROM items
303303
`)
304304

305+
await connection.execute(sql`
306+
-- @name: testInsert
307+
-- @db: db_mysql
308+
INSERT INTO items (food_type, points, time_takes_to_cook, table_id) VALUES (?, ?, 1, 1);
309+
`)
310+
311+
connection.destroy()
312+
305313
})();

0 commit comments

Comments
 (0)