Crate sqllogictest

Crate sqllogictest 

Source
Expand description

Sqllogictest parser and runner.

This crate supports multiple extensions beyond the original sqllogictest format. See the README for more information.

§Usage

For how to use the CLI tool backed by this library, see the README.

For using the crate as a lib, and implement your custom driver, see below.

Implement DB trait for your database structure:

struct MyDatabase {
    // fields
}

#[derive(thiserror::Error, Debug, PartialEq, Eq, Clone)]
enum MyError {
    // variants
}

impl sqllogictest::DB for MyDatabase {
    type Error = MyError;
    // Or define your own column type
    type ColumnType = sqllogictest::DefaultColumnType;
    fn run(
        &mut self,
        sql: &str,
    ) -> Result<sqllogictest::DBOutput<Self::ColumnType>, Self::Error> {
        // TODO
        Ok(sqllogictest::DBOutput::StatementComplete(0))
    }
}

// Then create a `Runner` on your database instance, and run the tests:
let mut tester = sqllogictest::Runner::new(|| async {
    let db = MyDatabase {
        // fields
    };
    Ok(db)
});
let _res = tester.run_file("../tests/slt/basic.slt");

// You can also parse the script and execute the records separately:
let records = sqllogictest::parse_file("../tests/slt/basic.slt").unwrap();
for record in records {
    let _res = tester.run(record);
}

Re-exports§

pub use self::column_type::*;
pub use self::connection::*;
pub use self::parser::*;
pub use self::runner::*;

Modules§

column_type
connection
harness
parser
Sqllogictest parser.
runner
Sqllogictest runner.
substitution

Macros§

harness
db_fn: fn() -> sqllogictest::AsyncDBpattern: The glob used to match against and select each file to be tested. It is relative to the root of the crate.