Skip to content
New issue

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

Mysql Create Not Working #2080

Closed
aramkumar06 opened this issue May 30, 2019 · 1 comment
Closed

Mysql Create Not Working #2080

aramkumar06 opened this issue May 30, 2019 · 1 comment

Comments

@aramkumar06
Copy link

aramkumar06 commented May 30, 2019

cargo 1.36.0-nightly
diesel = { version = "1.4.1", features = ["mysql"] }

Compiling mystore v0.1.0 (/home/desktop-64/Documents/Ram/rust/practical)
error[E0425]: cannot find value conn in this scope
--> src/models/product.rs:52:54
|
52 | products::table.order(products::id.desc()).first(conn).unwrap()
| ^^^^ not found in this scope

error[E0599]: no method named order found for type schema::products::table in the current scope
--> src/models/product.rs:52:21
|
52 | products::table.order(products::id.desc()).first(conn).unwrap()
| ^^^^^
|
::: src/schema.rs:1:1
|
1 | / table! {
2 | | products (id) {
3 | | id -> Int4,
4 | | name -> Varchar,
... |
7 | | }
8 | | }
| |_- method order not found for this
|
= help: items from traits can only be used if the trait is in scope
= note: the following traits are implemented but not in scope, perhaps add a use for one of them:
candidate #1: use crate::diesel::query_dsl::methods::OrderDsl;
candidate #2: use crate::diesel::QueryDsl;
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error[E0599]: no method named desc found for type schema::products::columns::id in the current scope
--> src/models/product.rs:52:40
|
52 | products::table.order(products::id.desc()).first(conn).unwrap()
| ^^^^
|
::: src/schema.rs:1:1
|
1 | / table! {
2 | | products (id) {
3 | | id -> Int4,
4 | | name -> Varchar,
... |
7 | | }
8 | | }
| |_- method desc not found for this
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope, perhaps add a use for it:
use crate::diesel::ExpressionMethods;
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: aborting due to 3 previous errors

@sgrif
Copy link
Member

sgrif commented May 30, 2019

The note sections tell you what's wrong and how to fix it (you're missing use diesel::prelude::*;)

@sgrif sgrif closed this as completed May 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants