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

Function should_validate_simple_select

tests/sqlite_query_parameters.rs:70–101  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

68
69 #[test]
70 fn should_validate_simple_select() -> Result<(), Box<dyn std::error::Error>> {
71 let schema = "CREATE TABLE items (id INTEGER PRIMARY KEY NOT NULL, name TEXT NOT NULL, price REAL);";
72
73 let ts_content = r#"
74import { sql } from 'sqlx-ts'
75
76const someQuery = sql`SELECT * FROM items`
77"#;
78
79 let (_, type_file) = run_sqlite_test(schema, ts_content, true)?;
80
81 let expected = r#"
82export type SomeQueryParams = [];
83
84export interface ISomeQueryResult {
85 id: number;
86 name: string;
87 price: number | null;
88}
89
90export interface ISomeQueryQuery {
91 params: SomeQueryParams;
92 result: ISomeQueryResult;
93}
94"#;
95
96 assert_eq!(
97 expected.trim().to_string().flatten(),
98 type_file.trim().to_string().flatten()
99 );
100 Ok(())
101 }
102
103 #[test]
104 fn should_handle_query_params_with_question_mark() -> Result<(), Box<dyn std::error::Error>> {

Callers

nothing calls this directly

Calls 1

run_sqlite_testFunction · 0.85

Tested by

no test coverage detected