Skip to main content

resolve_dialect_by_name

Function resolve_dialect_by_name 

Source
pub fn resolve_dialect_by_name(
    name: &str,
) -> Result<Arc<dyn PlatformDialect>, ResolveError>
Expand description

Resolve a platform name to the dialect that renders it.

This is the one resolver — all service crates call it instead of matching on names themselves. Each dialect declares the spellings it answers to, so "pg" reaches PostgreSQL and "mssql" reaches SQL Server because those dialects say so. Matching ignores case and surrounding whitespace, and an unknown name comes back with near-miss suggestions.

A dialect the host loaded at run time resolves the same way as one linked in: both are read off the registry.

§Errors

ResolveError::UnknownDialect, with suggestions, if no loaded dialect answers to the name; ResolveError::AmbiguousName if two do.

§Examples

use razeri_plugin_api::{ResolveError, resolve_dialect_by_name};

// Aliases, canonical names and casing all resolve to the same dialect.
let dialect = resolve_dialect_by_name("pg")?;
println!("{}", dialect.info().name);

let dialect = resolve_dialect_by_name("SNOWFLAKE")?;
let dialect = resolve_dialect_by_name("sqlite")?;