sea_query::extension::sqlite

Trait SqliteExpr

source
pub trait SqliteExpr: ExprTrait {
    // Provided methods
    fn glob<T>(self, right: T) -> SimpleExpr
       where T: Into<SimpleExpr> { ... }
    fn matches<T>(self, right: T) -> SimpleExpr
       where T: Into<SimpleExpr> { ... }
    fn get_json_field<T>(self, right: T) -> SimpleExpr
       where T: Into<SimpleExpr> { ... }
    fn cast_json_field<T>(self, right: T) -> SimpleExpr
       where T: Into<SimpleExpr> { ... }
}
Available on crate feature backend-sqlite only.

Provided Methods§

source

fn glob<T>(self, right: T) -> SimpleExpr
where T: Into<SimpleExpr>,

Express an sqlite GLOB operator.

§Examples
use sea_query::{extension::sqlite::SqliteExpr, tests_cfg::*, *};

let query = Query::select()
    .column(Font::Name)
    .from(Font::Table)
    .and_where(Expr::col(Font::Name).glob("a"))
    .to_owned();

assert_eq!(
    query.to_string(SqliteQueryBuilder),
    r#"SELECT "name" FROM "font" WHERE "name" GLOB 'a'"#
);
source

fn matches<T>(self, right: T) -> SimpleExpr
where T: Into<SimpleExpr>,

Express an sqlite MATCH operator.

§Examples
use sea_query::{extension::sqlite::SqliteExpr, tests_cfg::*, *};

let query = Query::select()
    .column(Font::Name)
    .from(Font::Table)
    .and_where(Expr::col(Font::Name).matches("a"))
    .to_owned();

assert_eq!(
    query.to_string(SqliteQueryBuilder),
    r#"SELECT "name" FROM "font" WHERE "name" MATCH 'a'"#
);
source

fn get_json_field<T>(self, right: T) -> SimpleExpr
where T: Into<SimpleExpr>,

Express an sqlite retrieves JSON field as JSON value (->).

§Examples
use sea_query::{extension::sqlite::SqliteExpr, tests_cfg::*, *};

let query = Query::select()
    .column(Font::Variant)
    .from(Font::Table)
    .and_where(Expr::col(Font::Variant).get_json_field("a"))
    .to_owned();

assert_eq!(
    query.to_string(SqliteQueryBuilder),
    r#"SELECT "variant" FROM "font" WHERE "variant" -> 'a'"#
);
source

fn cast_json_field<T>(self, right: T) -> SimpleExpr
where T: Into<SimpleExpr>,

Express an sqlite retrieves JSON field and casts it to an appropriate SQL type (->>).

§Examples
use sea_query::{extension::sqlite::SqliteExpr, tests_cfg::*, *};

let query = Query::select()
    .column(Font::Variant)
    .from(Font::Table)
    .and_where(Expr::col(Font::Variant).cast_json_field("a"))
    .to_owned();

assert_eq!(
    query.to_string(SqliteQueryBuilder),
    r#"SELECT "variant" FROM "font" WHERE "variant" ->> 'a'"#
);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§