Skip to content

Commit 555b092

Browse files
authored
Merge branch 'master' into feat/support-postgres-point-type
2 parents dec9bd5 + 1ef3f63 commit 555b092

File tree

171 files changed

+6110
-4588
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+6110
-4588
lines changed

.github/workflows/diesel.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
- '.github/workflows/diesel.yml'
77
- 'examples/diesel_*/**'
88
- 'sea-query-diesel/**'
9+
- 'src/**'
910
push:
1011
branches:
1112
- master
@@ -16,6 +17,7 @@ on:
1617
- '.github/workflows/diesel.yml'
1718
- 'examples/diesel_*/**'
1819
- 'sea-query-diesel/**'
20+
- 'src/**'
1921

2022
concurrency:
2123
group: ${{ github.workflow }}-${{ github.head_ref || github.ref || github.run_id }}
@@ -44,6 +46,7 @@ jobs:
4446
steps:
4547
- uses: actions/checkout@v4
4648
- uses: dtolnay/rust-toolchain@stable
49+
- run: cargo update --manifest-path sea-query-diesel/Cargo.toml -p [email protected] --precise=0.20.0
4750
- run: cargo build --manifest-path sea-query-diesel/Cargo.toml --workspace --features postgres,sqlite,mysql --features=with-chrono,with-json,with-rust_decimal,with-bigdecimal,with-uuid,with-time,with-ipnetwork,with-mac_address,postgres-array,postgres-vector
4851
- run: cargo build --manifest-path sea-query-diesel/Cargo.toml --workspace --features postgres,sqlite,mysql --features=with-chrono
4952
- run: cargo build --manifest-path sea-query-diesel/Cargo.toml --workspace --features postgres,sqlite,mysql --features=with-json
@@ -157,5 +160,6 @@ jobs:
157160
steps:
158161
- uses: actions/checkout@v4
159162
- uses: dtolnay/rust-toolchain@stable
163+
- run: cargo update --manifest-path examples/${{ matrix.example }}/Cargo.toml -p [email protected] --precise=0.20.0
160164
- run: cargo build --manifest-path examples/${{ matrix.example }}/Cargo.toml
161165
- run: cargo run --manifest-path examples/${{ matrix.example }}/Cargo.toml

.github/workflows/rust.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ jobs:
3535
toolchain: nightly
3636
components: rustfmt
3737
- run: cargo fmt --manifest-path Cargo.toml --all -- --check
38-
- run: cargo fmt --manifest-path sea-query-attr/Cargo.toml --all -- --check
3938
- run: cargo fmt --manifest-path sea-query-binder/Cargo.toml --all -- --check
4039
- run: cargo fmt --manifest-path sea-query-derive/Cargo.toml --all -- --check
4140
- run: cargo fmt --manifest-path sea-query-postgres/Cargo.toml --all -- --check

CHANGELOG.md

Lines changed: 229 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,242 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
## 1.0.0 - pending
9+
10+
### New features
11+
12+
* `#![forbid(unsafe_code)]` in all workspace crates https://github.com/SeaQL/sea-query/pull/930
13+
* Unify `Expr` and `SimpleExpr` as one type. `SimpleExpr` is kept as an alias of `Expr`, but they can now be used interchangably. There may be a few compile
14+
errors and some clippy warnings, basically just remove the redundant `.into()` https://github.com/SeaQL/sea-query/pull/889
15+
```rust
16+
pub type SimpleExpr = Expr; // !
17+
impl From<Expr> for SimpleExpr { .. } // now removed
18+
```
19+
* New `Iden` type system. Previously, `DynIden` is an alias to `SeaRc<dyn Iden>`, and is lazily rendered. Now, it's an `Cow<'static, str>`, and is eagerly rendered. `SeaRc` is no longer an alias to `Rc` / `Arc`, now is only a unit struct. As such, `Send` / `Sync` is no longer needed. It's still possible to dynamically serialize a String as identifier, see [example usage](https://github.com/SeaQL/sea-schema/blob/master/src/mysql/writer/types.rs). https://github.com/SeaQL/sea-query/pull/909
20+
```rust
21+
pub type DynIden = SeaRc<dyn Iden>; // old
22+
pub struct DynIden(pub(crate) Cow<'static, str>); // new
23+
24+
pub struct SeaRc<I>(pub(crate) RcOrArc<I>); // old
25+
pub struct SeaRc; // new
26+
```
27+
* Reworked `TableRef` and `ColumnRef` variants. `SchemaTable` is now a type alias of `TableName` https://github.com/SeaQL/sea-query/pull/927
28+
```rust
29+
// the following variants are collapsed into one:
30+
enum TableRef {
31+
Table(DynIden),
32+
SchemaTable(DynIden, DynIden),
33+
DatabaseSchemaTable(DynIden, DynIden, DynIden),
34+
TableAlias(DynIden, DynIden),
35+
SchemaTableAlias(DynIden, DynIden, DynIden),
36+
DatabaseSchemaTableAlias(DynIden, DynIden, DynIden, DynIden),
37+
..
38+
}
39+
// now it's just:
40+
enum TableRef {
41+
Table(TableName, Option<DynIden>), // optional Alias
42+
..
43+
}
44+
// because it's restructured to:
45+
pub struct DatabaseName(pub DynIden);
46+
pub struct SchemaName(pub Option<DatabaseName>, pub DynIden);
47+
pub struct TableName(pub Option<SchemaName>, pub DynIden);
48+
// so TableName can represent [database.][schema.]table
49+
```
50+
51+
### Enhancements
52+
53+
* Enable `clippy::nursery` https://github.com/SeaQL/sea-query/pull/938
54+
* Removed unnecessary `'static` bounds from type signatures https://github.com/SeaQL/sea-query/pull/921
55+
* Most `Value` variants are now unboxed (except `BigDecimal` and `Array`). Previously the size is 24 bytes. https://github.com/SeaQL/sea-query/pull/925
56+
```rust
57+
assert_eq!(std::mem::size_of::<Value>(), 32);
58+
```
59+
* `impl From<Expr> for Condition`. Now you can use `Expr` instead of `ConditionExpression`, which has been removed from the public API https://github.com/SeaQL/sea-query/pull/915
60+
```rust
61+
Cond::all().add(ConditionExpression::Expr(Expr::new(..))) // old
62+
Cond::all().add(Expr::new(..)) // new
63+
```
64+
* Replaced `serial` with `GENERATED BY DEFAULT AS IDENTITY` (Postgres) https://github.com/SeaQL/sea-query/pull/918
65+
```rust
66+
let table = Table::create()
67+
.table(Char::Table)
68+
.col(ColumnDef::new(Char::Id).integer().not_null().auto_increment().primary_key())
69+
.to_owned();
70+
71+
assert_eq!(
72+
table.to_string(PostgresQueryBuilder),
73+
[
74+
r#"CREATE TABLE "character" ("#,
75+
r#""id" integer GENERATED BY DEFAULT AS IDENTITY NOT NULL PRIMARY KEY,"#,
76+
r#")"#,
77+
].join(" ")
78+
);
79+
80+
// if you needed to support legacy system you can still do:
81+
let table = Table::create()
82+
.table(Char::Table)
83+
.col(ColumnDef::new(Char::Id).custom("serial").not_null().primary_key())
84+
.to_owned();
85+
86+
assert_eq!(
87+
table.to_string(PostgresQueryBuilder),
88+
[
89+
r#"CREATE TABLE "character" ("#,
90+
r#""id" serial NOT NULL PRIMARY KEY"#,
91+
r#")"#,
92+
].join(" ")
93+
);
94+
```
95+
96+
### Breaking Changes
97+
98+
* Removed inherent `SimpleExpr` methods that duplicate `ExprTrait`. If you encounter the following error, please add `use sea_query::ExprTrait` in scope https://github.com/SeaQL/sea-query/pull/890
99+
```rust
100+
error[E0599]: no method named `like` found for enum `sea_query::Expr` in the current scope
101+
|
102+
| Expr::col((self.entity_name(), *self)).like(s)
103+
|
104+
| fn like<L>(self, like: L) -> Expr
105+
| ---- the method is available for `sea_query::Expr` here
106+
|
107+
= help: items from traits can only be used if the trait is in scope
108+
help: trait `ExprTrait` which provides `like` is implemented but not in scope; perhaps you want to import it
109+
|
110+
-> + use sea_query::ExprTrait;
111+
```
112+
```rust
113+
error[E0308]: mismatched types
114+
--> src/sqlite/discovery.rs:27:57
115+
|
116+
| .and_where(Expr::col(Alias::new("type")).eq("table"))
117+
| -- ^^^^^^^ expected `&Expr`, found `&str`
118+
| |
119+
| arguments to this method are incorrect
120+
|
121+
= note: expected reference `&sea_query::Expr`
122+
found reference `&'static str`
123+
```
124+
* Added `non_exhaustive` to AST enums. It allows us to add new features and extend the AST without breaking the API. If you encounter the following error,
125+
please add a wildcard match `_ => {..}` https://github.com/SeaQL/sea-query/pull/891
126+
```rust
127+
error[E0004]: non-exhaustive patterns: `&_` not covered
128+
|
129+
| match table_ref {
130+
| ^^^^^^^^^ pattern `&_` not covered
131+
|
132+
note: `TableRef` defined here
133+
|
134+
| pub enum TableRef {
135+
| ^^^^^^^^^^^^^^^^^
136+
= note: the matched value is of type `&TableRef`
137+
= note: `TableRef` is marked as non-exhaustive, so a wildcard `_` is necessary to match exhaustively
138+
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
139+
|
140+
| TableRef::FunctionCall(_, tbl) => SeaRc::clone(tbl),
141+
-> | &_ => todo!(),
142+
```
143+
* `ExprTrait::eq` collided with `std::cmp::Eq`. If you encounter the following error, please use `std::cmp::PartialEq::eq(a, b)` or
144+
`sea_query::ExprTrait::eq(a, b)` explicitly https://github.com/SeaQL/sea-query/pull/890
145+
```rust
146+
error[E0308]: mismatched types
147+
|
148+
| fn eq(&self, other: &Self) -> bool {
149+
| ---- expected `bool` because of return type
150+
| format!("{:?}", self.0).eq(&format!("{:?}", other.0))
151+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `Expr`
152+
153+
For more information about this error, try `rustc --explain E0308`.
154+
error: could not compile `seaography` (lib) due to 1 previous error
155+
```
156+
* The method signature of `Iden::unquoted` is changed. If you're implementing `Iden` manually, you can modify it like below https://github.com/SeaQL/sea-query/pull/909
157+
```rust
158+
error[E0050]: method `unquoted` has 2 parameters but the declaration in trait `types::Iden::unquoted` has 1
159+
--> src/tests_cfg.rs:31:17
160+
|
161+
| fn unquoted(&self, s: &mut dyn std::fmt::Write) {
162+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 1 parameter, found 2
163+
|
164+
::: src/types.rs:63:17
165+
|
166+
| fn unquoted(&self) -> &str;
167+
| ----- trait requires 1 parameter
168+
```
169+
```rust
170+
impl Iden for Glyph {
171+
- fn unquoted(&self, s: &mut dyn fmt::Write) {
172+
+ fn unquoted(&self) -> &str {
173+
- write!(
174+
- s,
175+
- "{}",
176+
match self {
177+
Self::Table => "glyph",
178+
Self::Id => "id",
179+
Self::Tokens => "tokens",
180+
}
181+
- )
182+
- .unwrap();
183+
}
184+
}
185+
```
186+
* Removed `ConditionExpression` from the public API. Instead, just convert between `Condition` and `Expr` using `From`/`Into` https://github.com/SeaQL/sea-query/pull/915
187+
```rust
188+
error[E0603]: enum `ConditionExpression` is private
189+
--> tests/mysql/query.rs:734:20
190+
|
191+
> | use sea_query::ConditionExpression;
192+
| ^^^^^^^^^^^^^^^^^^^ private enum
193+
> | Cond::all().add(ConditionExpression::Expr(Expr::new(
194+
| ^^^^^^^^^^^^^^^^^^^ use of undeclared type `ConditionExpression`
195+
```
196+
```rust
197+
// simply do the following
198+
Cond::all().add(Expr::new(..))
199+
```
200+
201+
### Minor breaking changes
202+
203+
* Blanket-implemented `SqliteExpr` and `PgExpr` for `T where T: ExprTrait` https://github.com/SeaQL/sea-query/pull/914
204+
205+
Now you can use database-specific operators with all expression types.
206+
If you had custom implementations in your own code, some may no longer compile
207+
and may need to be deleted.
208+
* Replaced `ColumnSpec::Check(Expr)` with `ColumnSpec::Check(Check)` to support named check constraints https://github.com/SeaQL/sea-query/pull/920
209+
210+
### Upgrades
211+
212+
* Upgraded to Rust Edition 2024 https://github.com/SeaQL/sea-query/pull/885
213+
214+
## 0.32.7 - pending
215+
216+
### Bug Fixes
217+
218+
* Fix incorrect casting of `ChronoDateTimeWithTimeZone` in `Value::Array` https://github.com/SeaQL/sea-query/pull/933
219+
* Add missing parenthesis to `WINDOW` clause https://github.com/SeaQL/sea-query/pull/919
220+
```sql
221+
SELECT .. OVER "w" FROM "character" WINDOW "w" AS (PARTITION BY "ww")
222+
```
223+
* Fix serializing iden as a value in `ALTER TYPE ... RENAME TO ...` statements https://github.com/SeaQL/sea-query/pull/924
224+
```sql
225+
ALTER TYPE "font" RENAME TO "typeface"
226+
```
227+
* Fixed the issue where milliseconds were truncated when formatting `Value::Constant` https://github.com/SeaQL/sea-query/pull/929
228+
```sql
229+
'2025-01-01 00:00:00.000000'
230+
^^^^^^^
231+
```
232+
8233
## 0.32.6 - 2025-05-27
9234

10235
### Enhancements
11236

12-
* impl From<Condition> and From<ConditionExpression> for SimpleExpr https://github.com/SeaQL/sea-query/pull/886
237+
* impl `From<Condition>` and `From<ConditionExpression>` for `SimpleExpr` https://github.com/SeaQL/sea-query/pull/886
13238

14239
## 0.32.5 - 2025-05-07
15240

16241
### New features
17242

18-
* Support for creating functional indexes in PostgreSQL and MySQL https://github.com/SeaQL/sea-query/pull/869
243+
* Support for creating functional indexes in Postgres and MySQL https://github.com/SeaQL/sea-query/pull/869
19244

20245
### Enhancements
21246

@@ -236,7 +461,7 @@ assert_eq!(
236461

237462
### New Features
238463

239-
* Construct Postgres query with vector extension https://github.com/SeaQL/sea-query/pull/774
464+
* Construct Postgres query with vector extension https://github.com/SeaQL/sea-query/pull/774
240465
* Added `postgres-vector` feature flag
241466
* Added `Value::Vector`, `ColumnType::Vector`, `ColumnDef::vector()`, `PgBinOper::EuclideanDistance`, `PgBinOper::NegativeInnerProduct` and `PgBinOper::CosineDistance`
242467
```rust
@@ -898,7 +1123,7 @@ Enum {
8981123

8991124
### New Features
9001125

901-
* Added support `DROP COLUMN` for SQLite https://github.com/SeaQL/sea-query/pull/455
1126+
* Added support `DROP COLUMN` for SQLite https://github.com/SeaQL/sea-query/pull/455
9021127

9031128
### Bug Fixes
9041129

0 commit comments

Comments
 (0)