Working version with Pelton#8
Conversation
ms705
left a comment
There was a problem hiding this comment.
This looks good, but I left some comments for tweaks and a few questions.
What was the DateTime-related issue with this code? What you have seems entirely reasonable to me, but I recall you mentioned there is still an issue.
| let mut bg = backend.lock().unwrap(); | ||
| let res = bg.prep_exec( | ||
| "SELECT * FROM questions WHERE lec = ?", | ||
| "SELECT lec , q , question FROM questions WHERE lec = ?", |
There was a problem hiding this comment.
Why was this change necessary? Does Pelton not handle * correctly?
There was a problem hiding this comment.
Nothing to do with pelton. This is because I added the extra primary key column to questions, and we dont want to be selecting that.
| let mut insert_vals = String::new(); | ||
| let temp = vals.iter().map(|_| "?").collect::<Vec<&str>>().join(","); | ||
| insert_vals += &temp; |
There was a problem hiding this comment.
Seems like it just creates an empty string, concatenates the question marks using the same code removed from below and then appends to the empty string. Why is it needed -- the resulting string seems to be the same as the one that the code you removed below would have generated?
There was a problem hiding this comment.
I originally made these changes as I modified this method to make all necessary changes to inserts. I later changed that as you told me to but accidentally left this as is. Changing it now!
|
|
||
| pub fn replace(&mut self, table: &str, vals: Vec<Value>) { | ||
| self.do_insert(table, vals, true); | ||
| self.do_insert(table, vals, true); |
There was a problem hiding this comment.
spurious indentation; either remove or run cargo fmt to auto-format your Rust code.
| } else { | ||
| None | ||
| }, | ||
| time: NaiveDateTime::parse_from_str(&String::from_utf8(from_value::<Vec<u8>>(r[4].clone())).unwrap(), "%Y-%m-%d %H:%M:%S").ok() |
There was a problem hiding this comment.
As I now store the date as a string in the table, I made this edit to change that string to a NaiveDateTime as required by the rest of the code. The .ok() method at the end of this line returns an None if parse_from_string errors. And I believe that if we get None, the rest of the code decides to ignore the Date values, which is what seems to be happening as Dates are not getting printed in the frontend where they are supposed to.
I wan't able to find the issue with this line, its probably some silly mistake but it continues to elude me.
No description provided.