Skip to content

Commit 083cd2f

Browse files
committed
Edit
1 parent 72fcf86 commit 083cd2f

File tree

1 file changed

+97
-5
lines changed

1 file changed

+97
-5
lines changed

Blog/blog/2025-08-20-sea-query-1.0.md

Lines changed: 97 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,20 @@ If you were constructing / pattern matching `Value` variants manually, `Box::new
135135
### `non_exhaustive` AST enums
136136

137137
[#891](https://github.com/SeaQL/sea-query/pull/891)
138-
`#[non_exhaustive]` are added to all AST enums. It allows us to add new features and extend the AST without breaking the API. If you encounter the following error,
138+
`#[non_exhaustive]` are added to all AST enums. It allows us to add new features and extend the AST without breaking the API.
139+
140+
```rust
141+
+ #[non_exhaustive]
142+
enum Mode {
143+
Creation,
144+
Alter,
145+
TableAlter,
146+
}
147+
```
148+
149+
#### Potential compile errors
150+
151+
If you encounter the following error,
139152
please add a wildcard match `_ => {..}`
140153
```rust
141154
error[E0004]: non-exhaustive patterns: `&_` not covered
@@ -160,7 +173,7 @@ help: ensure that all possible cases are being handled by adding a match arm wit
160173
[#927](https://github.com/SeaQL/sea-query/pull/927)
161174
Previously, the `TableRef` variants are a product of all valid combinations of `Option<Database>`, `Option<Schema>`, `Table` and `Option<Alias>`. It is excessive and makes pattern matching difficult.
162175

163-
Now they're collapsed into one. `SchemaTable` is now simply a type alias of `TableName`. It makes constructing and pattern-matching `TableRef` much easier.
176+
Now they're collapsed into one. `SchemaTable` is now simply a type alias of `TableName`. It makes constructing and pattern-matching `TableRef` / `ColumnRef` much easier.
164177

165178
```rust
166179
// the following variants are collapsed into one:
@@ -178,16 +191,95 @@ enum TableRef {
178191
Table(TableName, Option<DynIden>), // optional Alias
179192
..
180193
}
181-
// because it's restructured to:
194+
182195
pub struct DatabaseName(pub DynIden);
183196
pub struct SchemaName(pub Option<DatabaseName>, pub DynIden);
197+
/// A table name, potentially qualified as [database.][schema.]table
184198
pub struct TableName(pub Option<SchemaName>, pub DynIden);
185-
// so TableName can represent [database.][schema.]table
186199
```
187200

201+
Similarly for `ColumnRef`:
202+
203+
```rust
204+
// before
205+
enum ColumnRef {
206+
Column(DynIden),
207+
TableColumn(DynIden, DynIden),
208+
SchemaTableColumn(DynIden, DynIden, DynIden),
209+
Asterisk,
210+
TableAsterisk(DynIden),
211+
}
212+
// now
213+
enum ColumnRef {
214+
/// A column name, potentially qualified as [database.][schema.][table.]column
215+
Column(ColumnName),
216+
/// An `*` expression, potentially qualified as [database.][schema.][table.]*
217+
Asterisk(Option<TableName>),
218+
}
219+
220+
pub struct ColumnName(pub Option<TableName>, pub DynIden);
221+
```
222+
223+
#### Potential compile errors
224+
225+
`TableRef`
226+
227+
```rust
228+
error[E0061]: this enum variant takes 2 arguments but 1 argument was supplied
229+
--> src/entity/relation.rs:526:15
230+
|
231+
> | from_tbl: TableRef::Table("foo".into_iden()),
232+
| ^^^^^^^^^^^^^^^-------------------
233+
| ||
234+
| |expected `TableName`, found `DynIden`
235+
| argument #2 of type `Option<DynIden>` is missing
236+
```
237+
It's recommended to use the `IntoTableRef` trait to convert types instead of constructing AST manually.
238+
```rust
239+
use sea_orm::sea_query::IntoTableRef;
240+
241+
from_tbl: "foo".into_table_ref(),
242+
```
243+
244+
`ColumnRef`
245+
246+
```rust
247+
error[E0277]: the trait bound `fn(std::option::Option<TableName>) -> sea_query::ColumnRef {sea_query::ColumnRef::Asterisk}: IntoColumnRef` is not satisfied
248+
--> src/executor/query.rs:1599:21
249+
|
250+
> | .column(ColumnRef::Asterisk)
251+
| ------ ^^^^^^^^^^^^^^^^^^^ the trait `sea_query::Iden` is not implemented for fn item `fn(std::option::Option<TableName>) -> sea_query::ColumnRef {sea_query::ColumnRef::Asterisk}`
252+
| |
253+
| required by a bound introduced by this call
254+
255+
error[E0308]: mismatched types
256+
--> src/executor/query.rs:1607:54
257+
|
258+
> | SimpleExpr::Column(ColumnRef::Column("id".into_iden()))
259+
| ----------------- ^^^^^^^^^^^^^^^^ expected `ColumnName`, found `DynIden`
260+
| |
261+
| arguments to this enum variant are incorrect
262+
```
263+
In the former case `Asterisk` has an additional inner `Option<TableName>`, you can simply put `None`.
264+
```rust
265+
.column(ColumnRef::Asterisk(None))
266+
```
267+
In the latter case, `&'static str` can now be used in most methods that accepts `ColumnRef`.
268+
```rust
269+
Expr::column("id")
270+
```
271+
272+
## New Features
273+
274+
### Query Audit
275+
276+
### Ergonomic raw SQL
277+
188278
## Release Plan
189279

190-
This is just one of many new features we've added while preparing [SeaQuery 1.0](https://github.com/SeaQL/sea-query/blob/master/CHANGELOG.md#100---pending). This is currently an `rc` release, if you have ideas please [join the discussion](https://github.com/SeaQL/sea-query/discussions/795).
280+
[SeaQuery 1.0](https://github.com/SeaQL/sea-query/blob/master/CHANGELOG.md#100---pending) is currently an `rc` release, and we plan to finalize it soon - meaning no more major breaking changes. If you feel adventurous or want to use some of the latest features, you can upgrade today. Please let us know the problems you faced, this will help us and the community. If you have ideas / feedback please [join the discussion](https://github.com/SeaQL/sea-query/discussions/795) on GitHub!
281+
282+
As SeaORM is based on top of SeaQuery, the breaking changes above would apply to all SeaORM users as well. We tried to minimize the impact to lightweight SeaORM users and most changes can be done mechanically. After that, it will be the most exciting release - SeaORM 2.0!
191283

192284
## Sponsor
193285

0 commit comments

Comments
 (0)