()
| 27 | } |
| 28 | |
| 29 | async fn setup_test_db() -> TestContext { |
| 30 | // Use unique temporary file for each test to avoid conflicts |
| 31 | let unique_id = Uuid::new_v4(); |
| 32 | let db_path = format!("/tmp/decimal_test_{}.db", unique_id); |
| 33 | let db_handler = DbHandler::new(&db_path).unwrap(); |
| 34 | let session_id = Uuid::new_v4(); |
| 35 | |
| 36 | // Create session connection |
| 37 | db_handler.create_session_connection(session_id).await.unwrap(); |
| 38 | |
| 39 | let ctx = TestContext { |
| 40 | db_handler, |
| 41 | session_id, |
| 42 | db_path: db_path.clone(), |
| 43 | }; |
| 44 | |
| 45 | // Create tables with NUMERIC columns |
| 46 | ctx.execute( |
| 47 | "CREATE TABLE accounts ( |
| 48 | id INTEGER PRIMARY KEY, |
| 49 | name TEXT, |
| 50 | balance TEXT, |
| 51 | credit_limit TEXT |
| 52 | )" |
| 53 | ).await.unwrap(); |
| 54 | |
| 55 | // Insert type metadata (use INSERT OR IGNORE to avoid conflicts) |
| 56 | ctx.execute( |
| 57 | "INSERT OR IGNORE INTO __pgsqlite_schema (table_name, column_name, pg_type, sqlite_type) VALUES |
| 58 | ('accounts', 'balance', 'NUMERIC', 'DECIMAL'), |
| 59 | ('accounts', 'credit_limit', 'NUMERIC', 'DECIMAL')" |
| 60 | ).await.unwrap(); |
| 61 | |
| 62 | ctx.execute( |
| 63 | "CREATE TABLE transactions ( |
| 64 | id INTEGER PRIMARY KEY, |
| 65 | account_id INTEGER, |
| 66 | amount TEXT, |
| 67 | fee TEXT, |
| 68 | type TEXT |
| 69 | )" |
| 70 | ).await.unwrap(); |
| 71 | |
| 72 | ctx.execute( |
| 73 | "INSERT OR IGNORE INTO __pgsqlite_schema (table_name, column_name, pg_type, sqlite_type) VALUES |
| 74 | ('transactions', 'amount', 'NUMERIC', 'DECIMAL'), |
| 75 | ('transactions', 'fee', 'NUMERIC', 'DECIMAL')" |
| 76 | ).await.unwrap(); |
| 77 | |
| 78 | ctx |
| 79 | } |
| 80 | |
| 81 | #[tokio::test] |
| 82 | async fn test_decimal_arithmetic_execution() { |
no test coverage detected