!lNGJpfiFVovXFJYmwx:matrix.org

Diesel

734 Members
A safe, extensible ORM and Query Builder for Rust10 Servers

Load older messages


Timestamp Message
19 Feb 2019
23:54:54@gitter_johnhalbert:matrix.orgJohn Halbert (Gitter)So, sometime mismatching on number of actual vs expected binds, or the prepared statement either exists or does not unexpectedly.
23:57:57@gitter_weiznich:matrix.orgGeorg Semmler (Gitter) Hmm, that should not happen. Could you provide some minimal example how to reproduce that? (Maybe as issue?)
23:59:00@gitter_johnhalbert:matrix.orgJohn Halbert (Gitter) Okay, yes, I can do that. Will open an issue. Just wanted to check first that there wasn't a simple solution.
20 Feb 2019
00:37:32@gitter_johnhalbert:matrix.orgJohn Halbert (Gitter) Actually, I'm seeing now this has to do with connection pool being provided by PgBouncer using transaction pooling, which disallows PREPARE/DEALLOCATE.
02:34:12@gitter_happycoder97:matrix.orgFarzeen (Gitter) @r-arias Here's what I went with: https://github.com/happycoder97/DSA-Testcases-Repo-Backend/blob/master/src/database/impl_crud.rs
02:41:13@gitter_happycoder97:matrix.orgFarzeen (Gitter) My current design:
I wanted the rest of my code to be entirely independent of what persistence mechanism I was using.
So I created a repository module with the required structs and some traits. https://github.com/happycoder97/DSA-Testcases-Repo-Backend/blob/master/src/repository.rs
But Rust doesn't allow to add #[derive(..)] to a struct after it has been defined. So I put all my struct inside a macro model_struct! { .. }. It is the responsibility of the implementor of repository to add the necessary derives to each struct inside model_struct! .
Here is the implementation of model_struct! for diesel: https://github.com/happycoder97/DSA-Testcases-Repo-Backend/blob/master/src/database/model_struct.rs
02:53:42@gitter_happycoder97:matrix.orgFarzeen (Gitter) PS: I would like to avoid typing table name inside model_struct! {...} in repository.rs, but I can't find a way to do it.
06:28:11@gitter_zegentzy:matrix.orgHal Gentz (Gitter) I think I've found a bug
06:29:13@gitter_zegentzy:matrix.orgHal Gentz (Gitter) https://i.imgur.com/kX0LMfa.png
06:29:39@gitter_zegentzy:matrix.orgHal Gentz (Gitter) https://i.imgur.com/q3dj4qB.png
06:30:22@gitter_zegentzy:matrix.orgHal Gentz (Gitter) Maybe I'm wrong, but 7 is not greater than 255 ;)
06:30:54@gitter_zegentzy:matrix.orgHal Gentz (Gitter) I'll have to investigate more tomorrow to figure out why this is happening...
06:32:13@gitter_zegentzy:matrix.orgHal Gentz (Gitter)Interestingly, 7 != 7 according to diesel...
06:37:05@gitter_zegentzy:matrix.orgHal Gentz (Gitter) For those interested, diesel is generating this sql when using eq
06:37:09@gitter_zegentzy:matrix.orgHal Gentz (Gitter) [src/account_actions.rs:314] diesel::debug_query::<crate::DbBack, _>(&e).to_string() = "SELECT `ddb_session_roots`.`ddb_id`, `ddb_session_token_pairs`.`ddb_id`, `ddb_session_token_pairs`.`ddb_user_id`, `ddb_session_token_pairs`.`ddb_scrypt_log_n` FROM (`ddb_session_token_pairs` INNER JOIN `ddb_session_roots` ON `ddb_session_token_pairs`.`ddb_root_id` = `ddb_session_roots`.`ddb_id`) WHERE `ddb_session_token_pairs`.`ddb_cookie_token` = ? AND `ddb_session_token_pairs`.`ddb_csrf_token` = ? AND `ddb_session_token_pairs`.`ddb_scrypt_log_n` = ? AND `ddb_session_roots`.`ddb_token_head_id` = `ddb_session_token_pairs`.`ddb_id` AND `ddb_session_roots`.`ddb_end_time` IS NULL AND `ddb_session_roots`.`ddb_start_time` >= ? AND `ddb_session_roots`.`ddb_ip` = ? AND `ddb_session_roots`.`ddb_is_ipv4` = ? -- binds: [[183, 164, 170, 206, 240, 134, 84, 218, 4, 114, 140, 129, 248, 112, 148, 236, 52, 94, 57, 12, 228, 157, 54, 91, 73, 110, 34, 141, 180, 171, 249, 160, 219, 18, 15, 204, 84, 174, 77, 217, 234, 110, 245, 20, 32, 29, 102, 40, 94, 117, 160, 128, 231, 130, 89, 41, 220, 39, 243, 173, 44, 57, 85, 254], [185, 158, 189, 141, 19, 85, 34, 20, 40, 116, 183, 169, 140, 99, 42, 74, 253, 83, 196, 237, 208, 104, 185, 192, 254, 105, 192, 92, 231, 99, 195, 174, 98, 59, 163, 124, 45, 46, 47, 118, 172, 165, 36, 183, 216, 149, 126, 230, 55, 137, 91, 109, 208, 55, 114, 170, 110, 197, 66, 73, 22, 144, 113, 6], [7], 1550643684, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0]]"
06:37:24@gitter_zegentzy:matrix.orgHal Gentz (Gitter) (edited) ```[src/account_actions.rs:314] diesel::debug_query::<crate::DbBack, ... => ``` [src/account_actions.rs:314] diesel::debug_query::<crate::DbBack, ...
06:48:29@gitter_zegentzy:matrix.orgHal Gentz (Gitter)Hehehe
06:48:43@gitter_zegentzy:matrix.orgHal Gentz (Gitter) This also yields nothing according to diesel: [src/account_actions.rs:315] diesel::debug_query::<crate::DbBack, _>(&e).to_string() = "SELECTddb_session_token_pairs.ddb_id,ddb_session_token_pairs.ddb_id,ddb_session_token_pairs.ddb_idFROMddb_session_token_pairsWHEREddb_session_token_pairs.ddb_scrypt_log_n= ? -- binds: [[7]]"
06:48:52@gitter_zegentzy:matrix.orgHal Gentz (Gitter) (edited) ... diesel: `[src/account_actions.rs:315] diesel::debug_query::<crate::DbBack, _>(&e).to_string() = "SELECT `ddb_session_token_pairs`.`ddb_id`, `ddb_session_token_pairs`.`ddb_id`, `ddb_session_token_pairs`.`ddb_id` FROM `ddb_session_token_pairs` WHERE `ddb_session_token_pairs`.`ddb_scrypt_log_n` = ? -- binds: [[7]]"` => ... diesel: ```[src/account_actions.rs:315] diesel::debug_query::<crate::DbBack, _>(&e).to_string() = "SELECT `ddb_session_token_pairs`.`ddb_id`, `ddb_session_token_pairs`.`ddb_id`, `ddb_session_token_pairs`.`ddb_id` FROM `ddb_session_token_pairs` WHERE `ddb_session_token_pairs`.`ddb_scrypt_log_n` = ? -- binds: [[7]]"```
06:49:45@gitter_zegentzy:matrix.orgHal Gentz (Gitter) Php admin says otherwise: https://i.imgur.com/KYWQRgH.png
09:01:48@gitter_r-arias:matrix.orgr-arias (Gitter) @happycoder97 thanks for the response! I'll have a look!
09:02:14@gitter_happycoder97:matrix.orgFarzeen (Gitter)Feel free to DM me if you have any further questions :)
09:03:20@gitter_r-arias:matrix.orgr-arias (Gitter)great, thanks :)
11:28:25@gitter_weiznich:matrix.orgGeorg Semmler (Gitter) @johnhalbert Why not just use a connection pool inside your applications? (That's provided by r2d2)
11:38:21@gitter_weiznich:matrix.orgGeorg Semmler (Gitter) @ZeGentzy As far as I can see the sql you tested in php admin does not match the sql produced by diesel. Therefore I would guess that is's just one of the other filters that prevents loading an result.
Not sure what's going on the the other problem, but without any further information about the schema, the generated query and the involved data it's not possible to help you there.
16:16:28@gitter_johnhalbert:matrix.orgJohn Halbert (Gitter) @weiznich the application won't scale using r2d2 alone. We're already using that. r2d2 has to maintain its own pool, but as new instances of these services come online, they eventually exhaust the connections allowed to the db. PgBouncer was chosen as it allows a reasonable number of connections to be allowed on the database (500 or so), while still allowing the application to scale out without exhausting those connections.
23:58:15@gitter_zegentzy:matrix.orgHal Gentz (Gitter) @weiznich It produced SELECT `ddb_session_token_pairs`.`ddb_id`, `ddb_session_token_pairs`.`ddb_id`, `ddb_session_token_pairs`.`ddb_id` FROM `ddb_session_token_pairs` WHERE `ddb_session_token_pairs`.`ddb_scrypt_log_n` = ? and I tested SELECT `ddb_session_token_pairs`.`ddb_id`, `ddb_session_token_pairs`.`ddb_id`, `ddb_session_token_pairs`.`ddb_id` FROM `ddb_session_token_pairs` WHERE `ddb_session_token_pairs`.`ddb_scrypt_log_n` = 7
23:58:32@gitter_zegentzy:matrix.orgHal Gentz (Gitter)Only difference is I got rid of the bind
23:58:46@gitter_zegentzy:matrix.orgHal Gentz (Gitter)Anyways, let me come up with a minimal example.
21 Feb 2019
01:53:37@gitter_dustinknopoff:matrix.orgDustin Knopoff (Gitter) I feel like I'm missing something really obvious, but I want to chain optional filters. That is, I have a struct Filters with fields that are optional. They all map to a column in a table. So for something like a Post, I would and a given filter Filter { count: Some(10), title: Some("Cookies"), author: None, /* etc */ } I'd like to chain a posts.filter(title.like(filter.title.unwrap()). It's a bit more complicated than that but that's the essential piece I can't figure out. I've tried using the into_boxed() method which does help with a couple things but it seems that any filters I apply are ignored. Thanks for the help!

There are no newer messages yet.


Back to Room List