We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi @treydempsey ,
we are having a weird issue with create method adding an entry to an sql table with two Uuid.
create
I have prepared an mvp here:
MVP issue Uuid
In the readme there is a more detailed explanation.
Thanks for your support in advance!
The text was updated successfully, but these errors were encountered:
Adding some comments about documentation...
If I try to assemble a small example based on this example it seems not working. Below here a code snippet:
use sqlx::FromRow; use sqlx_crud::SqlxCrud; use sqlx_crud::Crud; use sqlx::SqlitePool; use anyhow::Result; #[derive(Debug, FromRow, SqlxCrud)] pub struct User { pub user_id: i32, pub name: String, } #[tokio::main] async fn main() -> Result<()> { let db_url = "sqlite://test.db"; let pool = SqlitePool::connect(db_url).await?; let new_user = User { user_id: 1, name: "new_user".to_string() }; new_user.create(&pool).await?; if let Some(user) = User::by_id(&pool, 1).await? { println!("User: {:?}", user); } Ok(()) }
In migrations folder I have this sql:
CREATE TABLE users ( id INTEGER PRIMARY KEY NOT NULL, username TEXT NOT NULL );
Basically your example in crate docs. If I run with cargo run i get:
cargo run
Error: error returned from database: (code: 1) no such column: users.user_id Caused by: (code: 1) no such column: users.user_id
What did the magic for me is adding #[external_id] to the struct like that:
#[external_id]
#[derive(Debug, FromRow, SqlxCrud)] #[external_id] pub struct User { pub user_id: i32, pub name: String, }
I think some correction are needed anyway in the docs, but beside that is it ok that I use that attribute to make it work?
Thanks!
Sorry, something went wrong.
No branches or pull requests
Hi @treydempsey ,
we are having a weird issue with
create
method adding an entry to an sql table with two Uuid.I have prepared an mvp here:
MVP issue Uuid
In the readme there is a more detailed explanation.
Thanks for your support in advance!
The text was updated successfully, but these errors were encountered: