()
| 7 | use sqlparser::ast::{Query, Statement}; |
| 8 | |
| 9 | fn setup_test_db() -> Connection { |
| 10 | let conn = Connection::open_in_memory().unwrap(); |
| 11 | |
| 12 | // Initialize metadata table |
| 13 | TypeMetadata::init(&conn).unwrap(); |
| 14 | |
| 15 | // Register decimal functions |
| 16 | pgsqlite::functions::register_all_functions(&conn).unwrap(); |
| 17 | |
| 18 | // Create test tables |
| 19 | conn.execute( |
| 20 | "CREATE TABLE orders ( |
| 21 | id INTEGER PRIMARY KEY, |
| 22 | customer_id INTEGER, |
| 23 | total TEXT, |
| 24 | tax TEXT, |
| 25 | status TEXT |
| 26 | )", |
| 27 | [], |
| 28 | ).unwrap(); |
| 29 | |
| 30 | conn.execute( |
| 31 | "INSERT INTO __pgsqlite_schema (table_name, column_name, pg_type, sqlite_type) VALUES |
| 32 | ('orders', 'total', 'NUMERIC', 'DECIMAL'), |
| 33 | ('orders', 'tax', 'NUMERIC', 'DECIMAL')", |
| 34 | [], |
| 35 | ).unwrap(); |
| 36 | |
| 37 | conn.execute( |
| 38 | "CREATE TABLE customers ( |
| 39 | id INTEGER PRIMARY KEY, |
| 40 | name TEXT, |
| 41 | credit_limit TEXT, |
| 42 | discount_rate TEXT |
| 43 | )", |
| 44 | [], |
| 45 | ).unwrap(); |
| 46 | |
| 47 | conn.execute( |
| 48 | "INSERT INTO __pgsqlite_schema (table_name, column_name, pg_type, sqlite_type) VALUES |
| 49 | ('customers', 'credit_limit', 'NUMERIC', 'DECIMAL'), |
| 50 | ('customers', 'discount_rate', 'NUMERIC', 'DECIMAL')", |
| 51 | [], |
| 52 | ).unwrap(); |
| 53 | |
| 54 | conn.execute( |
| 55 | "CREATE TABLE products ( |
| 56 | id INTEGER PRIMARY KEY, |
| 57 | name TEXT, |
| 58 | price TEXT, |
| 59 | cost TEXT |
| 60 | )", |
| 61 | [], |
| 62 | ).unwrap(); |
| 63 | |
| 64 | conn.execute( |
| 65 | "INSERT INTO __pgsqlite_schema (table_name, column_name, pg_type, sqlite_type) VALUES |
| 66 | ('products', 'price', 'NUMERIC', 'DECIMAL'), |
no test coverage detected