-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: improve filter sql generation
Signed-off-by: Henry Gressmann <[email protected]>
- Loading branch information
1 parent
d551b71
commit 0d39c1b
Showing
7 changed files
with
173 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use duckdb::ToSql; | ||
|
||
pub struct ParamVec<'a>(Vec<Box<dyn ToSql + 'a>>); | ||
|
||
impl<'a> ParamVec<'a> { | ||
pub fn new() -> Self { | ||
Check warning on line 6 in src/utils/duckdb.rs GitHub Actions / Run tests on ubuntu-latest
|
||
Self(Vec::new()) | ||
} | ||
|
||
pub fn push<T: ToSql + 'a>(&mut self, value: T) { | ||
self.0.push(Box::new(value)); | ||
} | ||
|
||
pub fn extend_from_params(&mut self, params: ParamVec<'a>) { | ||
self.0.extend(params.0); | ||
} | ||
|
||
pub fn extend<T: ToSql + 'a>(&mut self, iter: impl IntoIterator<Item = T>) { | ||
self.0.extend(iter.into_iter().map(|v| Box::new(v) as Box<dyn ToSql + 'a>)); | ||
} | ||
} | ||
|
||
impl<'a> IntoIterator for ParamVec<'a> { | ||
type Item = Box<dyn ToSql + 'a>; | ||
type IntoIter = std::vec::IntoIter<Self::Item>; | ||
fn into_iter(self) -> Self::IntoIter { | ||
self.0.into_iter() | ||
} | ||
} | ||
|
||
pub fn repeat_vars(count: usize) -> String { | ||
assert_ne!(count, 0); | ||
let mut s = "?,".repeat(count); | ||
// Remove trailing comma | ||
s.pop(); | ||
s | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod duckdb; | ||
pub mod geo; | ||
pub mod hash; | ||
pub mod referrer; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.