Documentation Example Missing `.to_owned()` Call in Migration Examples
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 24
- Forks
- 68
- PR merge metrics
- No merged PRs in 30d
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()))
)
.await
Expected 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(),
)
.await
Versions
└── 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)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Writing Migration page, especially the Defining Migration and Schema Creation Methods sections linked in the issue. Add the documented .to_owned() call to the affected table-creation examples, then compile the migration example to confirm the type mismatch is resolved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100