belchior / sql_query_builder

Write SQL queries in a simple and composable way
https://crates.io/crates/sql_query_builder
MIT License
54 stars 5 forks source link

Changes the where clause behavior #11

Closed belchior closed 9 months ago

belchior commented 9 months ago

Breaking changes

This PR changes the behavior of the where clause to support the OR operator. The alias builder.and("...") was removed in favor of the builder.where_clause("...").

How to migrate

You will have to replace all use of the builder.and("...") to builder.where_clause("...")

New features

Was added in the Select, Update and Delete builders the method builder.where_or("...") to support concatenations using the OR operator.

use sql_query_builder as sql;

let query = sql::Select::new()
  .select("*")
  .from("users")
  .where_clause("login = 'joe'")
  .where_or("login = 'max'")
  .as_string();
SELECT *
FROM users
WHERE
  login = 'joe'
  OR login = 'max'