Skip to content

Commit

Permalink
issues-320 Remove deprecated methods (#380)
Browse files Browse the repository at this point in the history
  • Loading branch information
ikrivosheev committed Aug 20, 2022
1 parent 190eb50 commit b85fcf6
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 475 deletions.
6 changes: 4 additions & 2 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2160,8 +2160,10 @@ impl SimpleExpr {
/// let query = Query::select()
/// .columns([Char::Character, Char::SizeW, Char::SizeH])
/// .from(Char::Table)
/// .or_where(Expr::col(Char::SizeW).eq(1).and(Expr::col(Char::SizeH).eq(2)))
/// .or_where(Expr::col(Char::SizeW).eq(3).and(Expr::col(Char::SizeH).eq(4)))
/// .cond_where(any![
/// Expr::col(Char::SizeW).eq(1).and(Expr::col(Char::SizeH).eq(2)),
/// Expr::col(Char::SizeW).eq(3).and(Expr::col(Char::SizeH).eq(4)),
/// ])
/// .to_owned();
///
/// assert_eq!(
Expand Down
30 changes: 0 additions & 30 deletions src/foreign_key/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,36 +96,6 @@ impl ForeignKeyCreateStatement {
self
}

/// Set key table and referencing table
#[deprecated(
since = "0.10.2",
note = "Please use the [`ForeignKeyCreateStatement::from`] and [`ForeignKeyCreateStatement::to`]"
)]
pub fn table<T: 'static, R: 'static>(&mut self, table: T, ref_table: R) -> &mut Self
where
T: Iden,
R: Iden,
{
self.foreign_key.from_tbl(table);
self.foreign_key.to_tbl(ref_table);
self
}

/// Set key column and referencing column
#[deprecated(
since = "0.10.2",
note = "Please use the [`ForeignKeyCreateStatement::from`] and [`ForeignKeyCreateStatement::to`]"
)]
pub fn col<T: 'static, R: 'static>(&mut self, column: T, ref_column: R) -> &mut Self
where
T: Iden,
R: Iden,
{
self.foreign_key.from_col(column);
self.foreign_key.to_col(ref_column);
self
}

/// Set key table and columns
pub fn from<T, C>(&mut self, table: T, columns: C) -> &mut Self
where
Expand Down
10 changes: 0 additions & 10 deletions src/query/condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,16 +398,6 @@ pub trait ConditionalStatement {
self
}

#[deprecated(
since = "0.12.0",
note = "Please use [`ConditionalStatement::cond_where`]. Calling `or_where` after `and_where` will panic."
)]
/// Or where condition. This cannot be mixed with [`ConditionalStatement::and_where`].
/// Calling `or_where` after `and_where` will panic.
fn or_where(&mut self, other: SimpleExpr) -> &mut Self {
self.and_or_where(LogicalChainOper::Or(other))
}

#[doc(hidden)]
// Trait implementation.
fn and_or_where(&mut self, condition: LogicalChainOper) -> &mut Self;
Expand Down
6 changes: 4 additions & 2 deletions src/query/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ use crate::{
///
/// let query = Query::delete()
/// .from_table(Glyph::Table)
/// .or_where(Expr::col(Glyph::Id).lt(1))
/// .or_where(Expr::col(Glyph::Id).gt(10))
/// .cond_where(any![
/// Expr::col(Glyph::Id).lt(1),
/// Expr::col(Glyph::Id).gt(10),
/// ])
/// .to_owned();
///
/// assert_eq!(
Expand Down
28 changes: 0 additions & 28 deletions src/query/ordered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,6 @@ pub trait OrderedStatement {
})
}

#[deprecated(
since = "0.9.0",
note = "Please use the [`OrderedStatement::order_by`] with a tuple as [`ColumnRef`]"
)]
fn order_by_tbl<T, C>(&mut self, table: T, col: C, order: Order) -> &mut Self
where
T: IntoIden,
C: IntoIden,
{
self.order_by((table.into_iden(), col.into_iden()), order)
}

/// Order by [`SimpleExpr`].
fn order_by_expr(&mut self, expr: SimpleExpr, order: Order) -> &mut Self {
self.add_order_by(OrderExpr {
Expand Down Expand Up @@ -150,22 +138,6 @@ pub trait OrderedStatement {
self
}

#[deprecated(
since = "0.9.0",
note = "Please use the [`OrderedStatement::order_by_columns`] with a tuple as [`ColumnRef`]"
)]
fn order_by_table_columns<T, C>(&mut self, cols: Vec<(T, C, Order)>) -> &mut Self
where
T: IntoIden,
C: IntoIden,
{
self.order_by_columns(
cols.into_iter()
.map(|(t, c, o)| ((t.into_iden(), c.into_iden()), o))
.collect(),
)
}

/// Order by column with nulls order option.
///
/// # Examples
Expand Down
166 changes: 1 addition & 165 deletions src/query/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,18 +453,6 @@ impl SelectStatement {
self.expr(SimpleExpr::Column(col.into_column_ref()))
}

#[deprecated(
since = "0.9.0",
note = "Please use the [`SelectStatement::column`] with a tuple as [`ColumnRef`]"
)]
pub fn table_column<T, C>(&mut self, t: T, c: C) -> &mut Self
where
T: IntoIden,
C: IntoIden,
{
self.column((t.into_iden(), c.into_iden()))
}

/// Select columns.
///
/// # Examples
Expand Down Expand Up @@ -528,22 +516,6 @@ impl SelectStatement {
)
}

#[deprecated(
since = "0.9.0",
note = "Please use the [`SelectStatement::columns`] with a tuple as [`ColumnRef`]"
)]
pub fn table_columns<T, C>(&mut self, cols: Vec<(T, C)>) -> &mut Self
where
T: IntoIden,
C: IntoIden,
{
self.columns(
cols.into_iter()
.map(|(t, c)| (t.into_iden(), c.into_iden()))
.collect::<Vec<_>>(),
)
}

/// Select column.
///
/// # Examples
Expand Down Expand Up @@ -582,18 +554,6 @@ impl SelectStatement {
self
}

#[deprecated(
since = "0.6.1",
note = "Please use the [`SelectStatement::expr_as`] instead"
)]
pub fn expr_alias<T, A>(&mut self, expr: T, alias: A) -> &mut Self
where
T: Into<SimpleExpr>,
A: IntoIden,
{
self.expr_as(expr, alias)
}

/// Select column with window function.
///
/// # Examples
Expand Down Expand Up @@ -899,43 +859,6 @@ impl SelectStatement {
self.from_from(TableRef::ValuesList(value_tuples, alias.into_iden()))
}

#[deprecated(
since = "0.9.0",
note = "Please use the [`SelectStatement::from`] with a tuple as [`TableRef`]"
)]
/// From schema.table.
///
/// # Examples
///
/// ```
/// use sea_query::{tests_cfg::*, *};
///
/// let query = Query::select()
/// .column(Char::FontSize)
/// .from_schema(Char::Table, Glyph::Table)
/// .to_owned();
///
/// assert_eq!(
/// query.to_string(MysqlQueryBuilder),
/// r#"SELECT `font_size` FROM `character`.`glyph`"#
/// );
/// assert_eq!(
/// query.to_string(PostgresQueryBuilder),
/// r#"SELECT "font_size" FROM "character"."glyph""#
/// );
/// assert_eq!(
/// query.to_string(SqliteQueryBuilder),
/// r#"SELECT "font_size" FROM "character"."glyph""#
/// );
/// ```
pub fn from_schema<S: 'static, T: 'static>(&mut self, schema: S, table: T) -> &mut Self
where
S: IntoIden,
T: IntoIden,
{
self.from((schema, table))
}

/// From table with alias.
///
/// # Examples
Expand Down Expand Up @@ -995,36 +918,6 @@ impl SelectStatement {
self.from_from(tbl_ref.into_table_ref().alias(alias.into_iden()))
}

#[deprecated(
since = "0.6.1",
note = "Please use the [`SelectStatement::from_as`] instead"
)]
pub fn from_alias<R, A>(&mut self, tbl_ref: R, alias: A) -> &mut Self
where
R: IntoTableRef,
A: IntoIden,
{
self.from_as(tbl_ref, alias)
}

#[deprecated(
since = "0.9.0",
note = "Please use the [`SelectStatement::from_as`] with a tuple as [`TableRef`]"
)]
pub fn from_schema_as<S: 'static, T: 'static, A>(
&mut self,
schema: S,
table: T,
alias: A,
) -> &mut Self
where
S: IntoIden,
T: IntoIden,
A: IntoIden,
{
self.from_as((schema, table), alias)
}

/// From sub-query.
///
/// # Examples
Expand Down Expand Up @@ -1713,22 +1606,6 @@ impl SelectStatement {
self.group_by_columns(vec![col])
}

#[deprecated(
since = "0.9.0",
note = "Please use the [`SelectStatement::group_by_columns`] with a tuple as [`ColumnRef`]"
)]
pub fn group_by_table_columns<T, C>(&mut self, cols: Vec<(T, C)>) -> &mut Self
where
T: IntoIden,
C: IntoIden,
{
self.group_by_columns(
cols.into_iter()
.map(|(t, c)| (t.into_iden(), c.into_iden()))
.collect::<Vec<_>>(),
)
}

/// Add group by expressions from vector of [`SelectExpr`].
///
/// # Examples
Expand Down Expand Up @@ -1839,47 +1716,6 @@ impl SelectStatement {
self.cond_having(other)
}

#[deprecated(
since = "0.12.0",
note = "Please use [`ConditionalStatement::cond_having`]. Calling `or_having` after `and_having` will panic."
)]
/// Or having condition. Please use `cond_having` instead.
/// Calling `or_having` after `and_having` will panic.
///
/// # Examples
///
/// ```
/// use sea_query::{*, tests_cfg::*};
///
/// let query = Query::select()
/// .column(Glyph::Aspect)
/// .expr(Expr::col(Glyph::Image).max())
/// .from(Glyph::Table)
/// .group_by_columns(vec![
/// Glyph::Aspect,
/// ])
/// .or_having(Expr::col(Glyph::Aspect).gt(2))
/// .or_having(Expr::col(Glyph::Aspect).lt(8))
/// .to_owned();
///
/// assert_eq!(
/// query.to_string(MysqlQueryBuilder),
/// r#"SELECT `aspect`, MAX(`image`) FROM `glyph` GROUP BY `aspect` HAVING `aspect` > 2 OR `aspect` < 8"#
/// );
/// assert_eq!(
/// query.to_string(PostgresQueryBuilder),
/// r#"SELECT "aspect", MAX("image") FROM "glyph" GROUP BY "aspect" HAVING "aspect" > 2 OR "aspect" < 8"#
/// );
/// assert_eq!(
/// query.to_string(SqliteQueryBuilder),
/// r#"SELECT "aspect", MAX("image") FROM "glyph" GROUP BY "aspect" HAVING "aspect" > 2 OR "aspect" < 8"#
/// );
/// ```
pub fn or_having(&mut self, other: SimpleExpr) -> &mut Self {
self.having.add_and_or(LogicalChainOper::Or(other));
self
}

/// Limit the number of returned rows.
///
/// # Examples
Expand Down Expand Up @@ -2386,7 +2222,7 @@ impl QueryStatementWriter for SelectStatement {
/// .from(Glyph::Table)
/// .and_where(Expr::expr(Expr::col(Glyph::Aspect).if_null(0)).gt(2))
/// .order_by(Glyph::Image, Order::Desc)
/// .order_by_tbl(Glyph::Table, Glyph::Aspect, Order::Asc)
/// .order_by((Glyph::Table, Glyph::Aspect), Order::Asc)
/// .to_owned();
///
/// assert_eq!(
Expand Down
6 changes: 3 additions & 3 deletions src/query/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub trait QueryStatementWriter: QueryStatementBuilder {
/// .from(Glyph::Table)
/// .and_where(Expr::expr(Expr::col(Glyph::Aspect).if_null(0)).gt(2))
/// .order_by(Glyph::Image, Order::Desc)
/// .order_by_tbl(Glyph::Table, Glyph::Aspect, Order::Asc)
/// .order_by((Glyph::Table, Glyph::Aspect), Order::Asc)
/// .to_string(MysqlQueryBuilder);
///
/// assert_eq!(
Expand All @@ -75,7 +75,7 @@ pub trait QueryStatementWriter: QueryStatementBuilder {
/// .from(Glyph::Table)
/// .and_where(Expr::expr(Expr::col(Glyph::Aspect).if_null(0)).gt(2))
/// .order_by(Glyph::Image, Order::Desc)
/// .order_by_tbl(Glyph::Table, Glyph::Aspect, Order::Asc)
/// .order_by((Glyph::Table, Glyph::Aspect), Order::Asc)
/// .build(MysqlQueryBuilder);
///
/// assert_eq!(
Expand Down Expand Up @@ -106,7 +106,7 @@ pub trait QueryStatementWriter: QueryStatementBuilder {
/// .from(Glyph::Table)
/// .and_where(Expr::expr(Expr::col(Glyph::Aspect).if_null(0)).gt(2))
/// .order_by(Glyph::Image, Order::Desc)
/// .order_by_tbl(Glyph::Table, Glyph::Aspect, Order::Asc)
/// .order_by((Glyph::Table, Glyph::Aspect), Order::Asc)
/// .to_owned();
///
/// assert_eq!(
Expand Down
12 changes: 0 additions & 12 deletions src/query/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,6 @@ impl UpdateStatement {
self
}

#[deprecated(
since = "0.5.0",
note = "Please use the UpdateStatement::table function instead"
)]
#[allow(clippy::wrong_self_convention)]
pub fn into_table<T>(&mut self, table: T) -> &mut Self
where
T: IntoTableRef,
{
self.table(table)
}

/// Update column value by [`SimpleExpr`].
///
/// # Examples
Expand Down
Loading

0 comments on commit b85fcf6

Please sign in to comment.