MCPcopy Create free account
hub / github.com/JasonShin/sqlx-ts / should_handle_insert_with_params

Function should_handle_insert_with_params

tests/sqlite_query_parameters.rs:138–166  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

136
137 #[test]
138 fn should_handle_insert_with_params() -> Result<(), Box<dyn std::error::Error>> {
139 let schema = "CREATE TABLE items (id INTEGER PRIMARY KEY NOT NULL, name TEXT NOT NULL, price REAL);";
140
141 let ts_content = r#"
142import { sql } from 'sqlx-ts'
143
144const someQuery = sql`INSERT INTO items (name, price) VALUES (?, ?)`
145"#;
146
147 let (_, type_file) = run_sqlite_test(schema, ts_content, true)?;
148
149 let expected = r#"
150export type SomeQueryParams = [[string, number | null]];
151
152export interface ISomeQueryResult {
153}
154
155export interface ISomeQueryQuery {
156 params: SomeQueryParams;
157 result: ISomeQueryResult;
158}
159"#;
160
161 assert_eq!(
162 expected.trim().to_string().flatten(),
163 type_file.trim().to_string().flatten()
164 );
165 Ok(())
166 }
167
168 #[test]
169 fn should_handle_multiple_types() -> Result<(), Box<dyn std::error::Error>> {

Callers

nothing calls this directly

Calls 1

run_sqlite_testFunction · 0.85

Tested by

no test coverage detected