MCPcopy Create free account
hub / github.com/erans/pgsqlite / setup_test_db

Function setup_test_db

tests/subquery_cte_test.rs:9–72  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7use sqlparser::ast::{Query, Statement};
8
9fn 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'),

Callers 15

test_cte_basicFunction · 0.70
test_multiple_ctesFunction · 0.70
test_nested_ctesFunction · 0.70
test_correlated_subqueryFunction · 0.70
test_exists_subqueryFunction · 0.70
test_in_subqueryFunction · 0.70

Calls 2

register_all_functionsFunction · 0.85
executeMethod · 0.45

Tested by

no test coverage detected