pub struct TemplateInterceptor { /* private fields */ }
Expand description
Templated query, powered by minijinja. The template syntax can be found here.
Grammar:
-- SQLNESS TEMPLATE <json>
json
define data bindings passed to template, it should be a valid JSON string.
§Example
.sql
file:
-- SQLNESS TEMPLATE {"name": "test"}
SELECT * FROM table where name = "{{name}}"
.result
file:
-- SQLNESS TEMPLATE {"name": "test"}
SELECT * FROM table where name = "test";
In order to generate multiple queries, you can use the builtin function
sql_delimiter()
to insert a delimiter.
Trait Implementations§
Source§impl Debug for TemplateInterceptor
impl Debug for TemplateInterceptor
Source§impl Interceptor for TemplateInterceptor
impl Interceptor for TemplateInterceptor
fn before_execute( &self, execute_query: &mut Vec<String>, _context: &mut QueryContext, )
fn before_execute_async<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
execute_query: &'life1 mut Vec<String>,
context: &'life2 mut QueryContext,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn after_execute(&self, result: &mut String)
fn after_execute_async<'life0, 'life1, 'async_trait>(
&'life0 self,
result: &'life1 mut String,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Auto Trait Implementations§
impl Freeze for TemplateInterceptor
impl RefUnwindSafe for TemplateInterceptor
impl Send for TemplateInterceptor
impl Sync for TemplateInterceptor
impl Unpin for TemplateInterceptor
impl UnwindSafe for TemplateInterceptor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more