87 lines
2.9 KiB
Markdown
87 lines
2.9 KiB
Markdown
## Release Notes: sea-query 1.0.0-rc.33
|
|
|
|
*(since 1.0.0-rc.32)*
|
|
|
|
### New Features
|
|
|
|
* Add `Value::Enum` — a typed enum value that generates a literal cast in Postgres https://github.com/SeaQL/sea-query/pull/1051
|
|
|
|
```rust
|
|
let value = sea_query::Enum {
|
|
type_name: "FontSizeEnum".to_owned().into(),
|
|
value: "large".into(),
|
|
};
|
|
|
|
assert_eq!(
|
|
Query::insert()
|
|
.into_table(Char::Table)
|
|
.columns([Char::FontSize])
|
|
.values_panic([Expr::val(value)])
|
|
.to_string(PostgresQueryBuilder),
|
|
r#"INSERT INTO "character" ("font_size") VALUES ('large'::"FontSizeEnum")"#
|
|
);
|
|
```
|
|
|
|
Arrays of enum values are also supported (requires `postgres-array`):
|
|
|
|
```rust
|
|
let value = Value::Array(
|
|
ArrayType::Enum(Box::new("FontSizeEnum".to_owned().into())),
|
|
Some(Box::new(vec![
|
|
sea_query::Enum { type_name: "FontSizeEnum".to_owned().into(), value: "large".into() }.into(),
|
|
])),
|
|
);
|
|
|
|
// Generates: INSERT INTO "character" ("font_size") VALUES ($1::"FontSizeEnum"[])
|
|
```
|
|
|
|
* Add Postgres advisory lock functions https://github.com/SeaQL/sea-query/pull/1062
|
|
|
|
```rust
|
|
assert_eq!(
|
|
Query::select()
|
|
.expr(PgFunc::advisory_lock(Expr::val(12345_i64)))
|
|
.to_owned()
|
|
.to_string(PostgresQueryBuilder),
|
|
r#"SELECT PG_ADVISORY_LOCK(12345)"#
|
|
);
|
|
```
|
|
|
|
Full set of functions added: `PgFunc::advisory_lock`, `advisory_lock_shared`, `try_advisory_lock`, `try_advisory_lock_shared`, `advisory_unlock`, `advisory_unlock_shared`, `advisory_unlock_all`, `advisory_xact_lock`, `advisory_xact_lock_shared`, `try_advisory_xact_lock`, `try_advisory_xact_lock_shared`
|
|
|
|
* Add `SelectExprTrait` for ergonomic alias and window chaining https://github.com/SeaQL/sea-query/pull/1040
|
|
|
|
```rust
|
|
// Attach alias directly on an expression
|
|
Query::select()
|
|
.expr(Expr::col(Char::Character).alias("C"))
|
|
.from(Char::Table);
|
|
|
|
// Chain window function inline
|
|
Query::select()
|
|
.from(Char::Table)
|
|
.expr(
|
|
Expr::col(Char::Character)
|
|
.max()
|
|
.over(WindowStatement::partition_by(Char::FontSize))
|
|
.alias("C"),
|
|
);
|
|
|
|
// Reference a named window
|
|
Query::select()
|
|
.from(Char::Table)
|
|
.expr(Expr::col(Char::Character).max().over("w"))
|
|
.window("w", WindowStatement::partition_by(Char::FontSize));
|
|
```
|
|
|
|
### Enhancements
|
|
|
|
* Allow schema-referencing foreign keys in SQLite backend — the schema qualifier is stripped since SQLite foreign key syntax does not support it https://github.com/SeaQL/sea-query/pull/1056
|
|
* Fix null array handling: `Array::Null.is_empty()` now correctly returns `false`; null and empty are distinct states https://github.com/SeaQL/sea-query/pull/1034
|
|
* Rename `Value::as_ref_array` to `Value::as_array`; old name kept as a deprecated alias https://github.com/SeaQL/sea-query/pull/1034
|
|
* Add `PostgresValues::as_types()` — returns the corresponding `postgres::Type` for each bound value https://github.com/SeaQL/sea-query/pull/967
|
|
|
|
### House Keeping
|
|
|
|
* Simplify `FunctionCall::new(PgFunc::...)` calls
|