cargo sea-query 0.25.0

latest releases: 1.0.1, 1.0.0, 1.0.0-rc.34...
4 years ago

New Features

  • CASE WHEN statement support #304
  • Add support for Ip(4,6)Network and MacAddress #309
  • [sea-query-attr] macro for deriving Iden enum from struct #300
  • Add ability to alter foreign keys #299
  • Select DISTINCT ON #313

Enhancements

  • Insert Default #266
  • Make sea-query-driver an optional dependency #324
  • Add ABS function #334
  • Support IF NOT EXISTS when create index #332
  • Support different blob types in MySQL #314
  • Add VarBinary column type #331
  • Returning expression supporting SimpleExpr #335

Bug fixes

  • Fix arguments when nesting custom expressions #333
  • Fix clippy warnings for manual map #337

Breaking Changes

  • Introducing a dedicated ReturningClause instead of reusing Select on returning: #317
.returning(Query::select().column(Glyph::Id).take()) // before
.returning(Query::returning().columns([Glyph::Id])) // now
  • In #333, the custom expression API changed for Postgres, users should change their placeholder from ? to Postgres's $N
let query = Query::select()
    .columns([Char::Character, Char::SizeW, Char::SizeH])
    .from(Char::Table)
    .and_where(Expr::col(Char::Id).eq(1))
    .and_where(Expr::cust_with_values("6 = $2 * $1", vec![3, 2]).into())
    .to_owned();

assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"SELECT "character", "size_w", "size_h" FROM "character" WHERE "id" = 1 AND 6 = 2 * 3"#
);

As a side effect, ?? is no longer needed for escaping ?

let query = Query::select()
    .expr(Expr::cust_with_values(
        "data @? ($1::JSONPATH)",
        vec!["hello"],
    ))
    .to_owned();

assert_eq!(
    query.to_string(PostgresQueryBuilder),
    r#"SELECT data @? ('hello'::JSONPATH)"#
);
  • In #314, ColumnType's Binary(Option<u32>) changed to Binary(BlobSize), so if you used Binary(None) before, you should change to Binary(BlobSize::Blob(None))

New Contributors

Full Changelog: 0.24.0...0.25.0

Don't miss a new sea-query release

NewReleases is sending notifications on new releases.