!lNGJpfiFVovXFJYmwx:matrix.org

Diesel

1433 Members
A safe, extensible ORM and Query Builder for Rust58 Servers

Load older messages


SenderMessageTime
28 Sep 2020
@gitter_nanolsn:matrix.orgNano (Gitter) (edited) Finally it worked, I configured a little the ldconfig. I also made a mistake on the command line, to specify several features, it needs to use like `--features "postgres sqlite"` => Hi everyone! I was learning diesel with sqlite. Then I install postgresql and tried to use it. But I have installed diesel_cli with only sqlite feature. Now I need to reinstall diesel_cli with postgres, therefore I run: ``` cargo install --force diesel_cli --no-default-features --features postgres sqlite ``` But then I got an error: ``` error: linking with `cc` failed: exit code: 1 *a super long compiler options line* = note: /usr/bin/ld: cannot find -lpq collect2: error: ld returned 1 exit status error: aborting due to previous error error: failed to compile `diesel_cli v1.4.1`, intermediate artifacts can be found at `/tmp/cargo-installYTfa1P` Caused by: could not compile `diesel_cli`. ``` Can anyone know how to solve this problem? (OS: Ubuntu) 12:13:55
@gitter_weiznich:matrix.orgGeorg Semmler (Gitter) As mysql does not provide a feature like RETURNING clauses you can only do an additional query that orders by your primary key and returns the latest result. 12:14:44
@gitter_hoangtranwork:matrix.orgHoang Tran (Gitter) (edited) ... MySql backend? => ... MySql backend? 12:14:44
@gitter_thebird_gitlab:matrix.orgTim Reynolds (Gitter)
error[E0599]: no method named `eq` found for struct `schema::images::table` in the current scope
  --> src/routes/images.rs:55:32
   |
55 |       match images.filter(images.eq(&item.link)).first::<Image>(&conn) {
   |                                  ^^ method not found in `schema::images::table`
   | 
  ::: src/schema.rs:1:1
   |
1  | / table! {
2  | |     images (id) {
3  | |         id -> Int4,
4  | |         link -> Text,
...  |
7  | |     }
8  | | }
   | |_- method `eq` not found for this
   |
   = note: the method `eq` exists but the following trait bounds were not satisfied:
           `&mut schema::images::table : diesel::ExpressionMethods`
           `&mut schema::images::table : std::iter::Iterator`
           `&schema::images::table : diesel::ExpressionMethods`
           `schema::images::table : diesel::ExpressionMethods`
   = help: items from traits can only be used if the trait is implemented and in scope
   = note: the following traits define an item `eq`, perhaps you need to implement one of them:
           candidate #1: `std::cmp::PartialEq`
           candidate #2: `std::iter::Iterator`
           candidate #3: `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)
12:15:37
@gitter_thebird_gitlab:matrix.orgTim Reynolds (Gitter) @weiznich , sorry, this is the complete error. 12:15:49
@gitter_thebird_gitlab:matrix.orgTim Reynolds (Gitter)Corresponding function; 12:16:37
@gitter_weiznich:matrix.orgGeorg Semmler (Gitter) Sounds like you miss a include to diesel::ExpressionMethods or diesel::prelude::* in that scope. 12:16:42
@gitter_thebird_gitlab:matrix.orgTim Reynolds (Gitter) It's there. I also tried including it within in the function itself. 12:17:17
@gitter_weiznich:matrix.orgGeorg Semmler (Gitter)The error message indicates quite clearly that it is not there.12:17:46
@gitter_weiznich:matrix.orgGeorg Semmler (Gitter)Please double check that.12:17:51
@gitter_thebird_gitlab:matrix.orgTim Reynolds (Gitter) It's there. 12:19:54
@gitter_thebird_gitlab:matrix.orgTim Reynolds (Gitter) https://gist.github.com/kilroyjones/e92fc0f9417a6bf9ecb6ca30324e1c3f 12:19:56
@gitter_weiznich:matrix.orgGeorg Semmler (Gitter) The filter line does not make any sense. You cannot call .eq on a table. 12:21:42
@gitter_weiznich:matrix.orgGeorg Semmler (Gitter)That needs to be a column definition.12:21:55
@gitter_thebird_gitlab:matrix.orgTim Reynolds (Gitter) But it works here: https://gist.github.com/kilroyjones/872c9e6ff2643d5cc5c24b015ec77cd6 12:22:03
@gitter_weiznich:matrix.orgGeorg Semmler (Gitter) that's different. links and link vs images and images 12:22:42
@gitter_thebird_gitlab:matrix.orgTim Reynolds (Gitter)ahh damnit. thanks12:23:38
@gitter_thebird_gitlab:matrix.orgTim Reynolds (Gitter)probably needed to step away for a second. 12:24:01
@gitter_thebird_gitlab:matrix.orgTim Reynolds (Gitter)much thanks :)12:24:08
@gitter_hoangtranwork:matrix.orgHoang Tran (Gitter) Thank you!, while MySql doesn’t support RETURNING, I believe they still support something that return the last inserted ID, if such ID is all I need then do we have a way to get it, or just another query? 18:14:38
@gitter_hoangtranwork:matrix.orgHoang Tran (Gitter) Hello, what’s the most convenient way to mimic .get_result() on MySql backend? 18:14:44
@gitter_hoangtranwork:matrix.orgHoang Tran (Gitter) (edited) Thank you!, while MySql doesn’t support `RETURNING`, I believe they still support something that return the last inserted ID, if such ID is all I need then do we have a way to get it, or just another query? => Hello, what’s the most convenient way to mimic `.get_result()` on MySql backend? 18:15:11
@gitter_hoangtranwork:matrix.orgHoang Tran (Gitter)also, should the 2 query be in a transaction to avoid some other rows sneaking in the middle?18:15:13
29 Sep 2020
@allsyed:matrix.org@allsyed:matrix.org left the room.01:32:13
@gitter_weiznich:matrix.orgGeorg Semmler (Gitter) There is also a sql function named LAST_INSERT_ID() . You can use this, but it's basically the same as ordering by id and selecting the last entry. Only that it hides that behind a function call. 07:22:41
@gitter_hoangtranwork:matrix.orgHoang Tran (Gitter) (edited) also, should the 2 query be in a transaction to avoid some other rows sneaking in the middle? => Hello, what’s the most convenient way to mimic `.get_result()` on MySql backend? 07:22:40
@gitter_hoangtranwork:matrix.orgHoang Tran (Gitter) (edited) ... MySql backend? => ... MySql backend? 07:23:24
@gitter_weiznich:matrix.orgGeorg Semmler (Gitter) You can use no_arg_sql_function! to define that function on your own. 07:23:24
@gitter_weiznich:matrix.orgGeorg Semmler (Gitter)And yes you should wrap that into a transaction to have at least some confidence that nothing else can blow up that construct. (That does not necessarily guarantee that…)07:24:12
@gitter_hoangtranwork:matrix.orgHoang Tran (Gitter) (edited) ... MySql backend? => ... MySql backend? 07:24:12

There are no newer messages yet.


Back to Room List