CodeVetter · Repo Unpack · Behavior traces
diesel-rs/diesel
The inspected flows cover CLI startup, database setup, migration application, schema printing, query execution, and example operations. Each trace follows named functions across their implementation boundaries. Migration application reaches both SQL execution and version bookkeeping before optional schema regeneration. PostgreSQL query tracing distinguishes cached named statements from uncached parameterized execution.
- Startup: main calls inner_main, which initializes DIESEL_LOG tracing, invokes dotenvy::dotenv, tolerates a missing dotenv file, parses Cli, and dispatches; returned errors are printed before exit code 1.
- Setup: run_setup_command calls create_migrations_dir and create_config_file, then setup_database resolves the URL, creates the database if needed, optionally creates default migrations, and invokes schema-table setup/migration execution.
- Migration run: run_migration_command calls conn_and_migration_dir, which establishes InferConnection and validates FileBasedMigrations; run_migrations_with_output delegates to HarnessWithOutput::run_pending_migrations, then regenerates schema unless --no-schema.
- Migration persistence: run_pending_migrations calls pending_migrations, removes already applied versions and sorts remaining versions ascending, then run_migration executes SQL and inserts bookkeeping inside a transaction when metadata permits.
- Print schema: run_infer_schema establishes a connection, reads/overrides configuration, computes multi-schema context, and calls run_print_schema; output_schema discovers relations and foreign keys, resolves metadata, formats/patches Rust, then writes stdout.
- PostgreSQL load: RunQueryDsl::load calls internal_load and collects results; internal_load calls connection.load, which uses with_prepared_query, inner_load, Statement::execute, and the selected loading mode's cursor before row deserialization.
- PostgreSQL execution branch: Statement::execute builds parameter pointers/lengths, rejects counts or sizes exceeding i32, sends named statements through send_query_prepared or unnamed SQL through send_query_params, optionally enables row-by-row mode, and retrieves a result.
- Blog create-post: run_cli establishes PgConnection, current_user delegates to current_user_from_env/find_user and Argon2 verification, editor::edit_string round-trips a temporary file through an external editor, then insert_into returns the post ID.