-
-
Notifications
You must be signed in to change notification settings - Fork 56
Open
Description
Description
The migration documentation at Writing Migration contains code examples that are missing a necessary .to_owned() call. This omission causes a compile-time type mismatch error when trying to create tables.
Steps to Reproduce
- Copy the code example from the documentation (see below).
- Attempt to compile the migration.
manager
.create_table(
Table::create()
.table(Post::Table)
.if_not_exists()
.col(pk_auto(Post::Id))
.col(string(Post::Title))
.col(string(Post::Text))
.col(enumeration_null(Post::Category, Alias::new("category"), Category::iter()))
)
.awaitExpected Behavior
The code example should compile without errors.
Actual Behavior
Error Message Received:
error[E0308]: mismatched types
--> migration\src\m20220101_000001_create_table.rs:37:17
|
36 | .create_table(
| ------------ arguments to this method are incorrect
37 | / Table::create()
38 | | .table(Post::Table)
39 | | .if_not_exists()
40 | | .col(pk_auto(Post::Id))
... |
46 | | Category::iter(),
47 | | )),
| |______________________^ expected `TableCreateStatement`, found `&mut TableCreateStatement`
Workaround
Appending .to_owned() to the table creation chain fixes the issue. For example:
manager
.create_table(
Table::create()
.table(Post::Table)
.if_not_exists()
.col(pk_auto(Post::Id))
.col(string(Post::Title))
.col(string(Post::Text))
.col(enumeration_null(
Post::Category,
Alias::new("category"),
Category::iter(),
))
.to_owned(),
)
.awaitVersions
βββ sea-orm-migration v1.1.4
βββ sea-orm v1.1.4
β βββ sea-orm-macros v1.1.4 (proc-macro)
β β βββ sea-bae v0.2.1 (proc-macro)
β βββ sea-query v0.32.1
β β βββ sea-query-derive v0.4.2 (proc-macro)
βββ sea-orm-cli v1.1.4
β βββ sea-schema v0.16.1
β β βββ sea-query v0.32.1 (*)
β β βββ sea-schema-derive v0.3.0 (proc-macro)
βββ sea-schema v0.16.1 (*)
- OS: Windows 10.0.26100 x86_64 (X64)
β MSVC: Visual Studio ηζε·₯ε
· 2022
β rustc: 1.84.1 (e71f9a9a9 2025-01-27)
β cargo: 1.84.1 (66221abde 2024-11-19)
β rustup: 1.27.1 (54dd3d00f 2024-04-24)
β Rust toolchain: stable-x86_64-pc-windows-msvc (default)
Metadata
Metadata
Assignees
Labels
No labels