Skip to content

Commit

Permalink
fix: fixed quote style param bug (#100)
Browse files Browse the repository at this point in the history
* fix: fixed quote style param bug

* test: add some quoted fields in insert tests

* test: revert mysql test as it does not support quoted fields
  • Loading branch information
JasonShin authored Apr 4, 2024
1 parent 63f9efe commit 67dad03
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/ts_generator/sql_parser/translate_insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ pub async fn translate_insert(
let placeholder = get_expr_placeholder(value);

if placeholder.is_some() {
let match_col = columns
let match_col = &columns
.get(column)
.unwrap_or_else(|| {
panic!("Matching column of idx {column} is not found while processing insert params")
})
.to_string();
.value;

let field = table_details.get(match_col.as_str()).unwrap_or_else(|| {
panic!("Column {match_col} is not found while processing insert params")
Expand Down
4 changes: 2 additions & 2 deletions tests/postgres_insert_query_parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ run_test!(should_pick_query_params_from_single_row_of_values, TestConfig::new("p
//// TS query ////
r#"
const someInputQuery = sql`
INSERT INTO items (id, food_type, time_takes_to_cook, table_id, points)
INSERT INTO items (id, "food_type", time_takes_to_cook, table_id, points)
VALUES
($2, $1, 2, $3, 2);
`
Expand All @@ -43,7 +43,7 @@ run_test!(should_pick_query_params_from_multiple_rows_of_values, TestConfig::new
//// TS query ////
r#"
const someInputQuery = sql`
INSERT INTO items (id, food_type, time_takes_to_cook, table_id, points)
INSERT INTO items (id, "food_type", time_takes_to_cook, table_id, points)
VALUES
($2, $1, 2, $3, 2),
($5, 'test', $4, $7, $6);
Expand Down

0 comments on commit 67dad03

Please sign in to comment.