Skip to content

Commit

Permalink
feat(driver-adapters): add "version()" support to QuaintQueryable
Browse files Browse the repository at this point in the history
  • Loading branch information
jkomyno committed Jan 6, 2025
1 parent 4549dd9 commit e90eba9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
5 changes: 0 additions & 5 deletions quaint/src/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ pub trait Visitor<'a> {
/// Write to the query.
fn write<D: fmt::Display>(&mut self, s: D) -> Result;

/// Name of the function used to view the version of the database.
fn version_fn(&self) -> &'static str {
"version"
}

/// A point to modify an incoming query to make it compatible with the
/// underlying database.
fn compatibility_modifications(&self, query: Query<'a>) -> Query<'a> {
Expand Down
5 changes: 5 additions & 0 deletions quaint/src/visitor/mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ pub struct Mysql<'a> {
}

impl<'a> Mysql<'a> {
/// Name of the function used to view the version of the database.
pub const fn version_fn() -> &'static str {
"version"
}

fn visit_regular_equality_comparison(&mut self, left: Expression<'a>, right: Expression<'a>) -> visitor::Result {
self.visit_expression(left)?;
self.write(" = ")?;
Expand Down
5 changes: 5 additions & 0 deletions quaint/src/visitor/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ pub struct Postgres<'a> {
}

impl<'a> Postgres<'a> {
/// Name of the function used to view the version of the database.
pub const fn version_fn() -> &'static str {
"version"
}

fn visit_json_build_obj_expr(&mut self, expr: Expression<'a>) -> crate::Result<()> {
match expr.kind() {
ExpressionKind::Column(col) => match (col.type_family.as_ref(), col.native_type.as_deref()) {
Expand Down
9 changes: 5 additions & 4 deletions quaint/src/visitor/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ pub struct Sqlite<'a> {
}

impl<'a> Sqlite<'a> {
/// Name of the function used to view the version of the database.
pub const fn version_fn() -> &'static str {
"sqlite_version"
}

fn returning(&mut self, returning: Option<Vec<Column<'a>>>) -> visitor::Result {
if let Some(returning) = returning {
if !returning.is_empty() {
Expand Down Expand Up @@ -95,10 +100,6 @@ impl<'a> Visitor<'a> for Sqlite<'a> {
Ok(())
}

fn version_fn(&self) -> &'static str {
"sqlite_version"
}

fn visit_raw_value(&mut self, value: Value<'a>) -> visitor::Result {
let res = match &value.typed {
ValueType::Int32(i) => i.map(|i| self.write(i)),
Expand Down

0 comments on commit e90eba9

Please sign in to comment.