qail_core/transpiler/sql/
oracle.rs1use super::super::traits::SqlGenerator;
2
3pub struct OracleGenerator;
4
5impl SqlGenerator for OracleGenerator {
6 fn quote_identifier(&self, id: &str) -> String {
7 format!("\"{}\"", id.replace('"', "\"\""))
9 }
10
11 fn placeholder(&self, index: usize) -> String {
12 format!(":{}", index)
14 }
15
16 fn fuzzy_operator(&self) -> &str {
17 "LIKE"
18 }
19
20 fn bool_literal(&self, val: bool) -> String {
21 if val { "1".to_string() } else { "0".to_string() }
24 }
25
26 fn string_concat(&self, parts: &[&str]) -> String {
27 parts.join(" || ")
28 }
29
30 fn limit_offset(&self, limit: Option<usize>, offset: Option<usize>) -> String {
31 let mut sql = String::new();
35 let off = offset.unwrap_or(0);
36
37 if limit.is_some() || offset.is_some() {
38 sql.push_str(&format!(" OFFSET {} ROWS", off));
39
40 if let Some(lim) = limit {
41 sql.push_str(&format!(" FETCH NEXT {} ROWS ONLY", lim));
42 }
43 }
44
45 sql
46 }
47}