Skip to main content

mysql

Function mysql 

Source
pub const fn mysql<const N: usize>(spec: &TableSpec<'_>) -> Sql<N>
Expand description

The MySQL and MariaDB insert of spec: every column the database does not fill, in TableSpec::columns order, bound as ?; () VALUES () when there is none.

§Panics

When the text outgrows N, when the description reads the table with * (TableSpec::selecting_all), or when a name is longer than the 64 characters MySQL keeps. In a const the panic is a build error.

§Examples

use ruststream_sqlx_dialect::insert::{self, Sql};
use ruststream_sqlx_dialect::{Column, Form, TableSpec};

const ORDERS: TableSpec<'static> =
    TableSpec::new("order_jobs", Column::new("job_id").generated(), Form::RowLock)
        .payload(Column::new("payload"));
const INSERT: Sql<64> = insert::mysql(&ORDERS);

assert_eq!(INSERT.as_str(), "INSERT INTO `order_jobs` (`payload`) VALUES (?)");