-
Notifications
You must be signed in to change notification settings - Fork 12
Working version with Pelton #8
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
base: pelton
Are you sure you want to change the base?
Conversation
ms705
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this change necessary? Does Pelton not handle * correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
src/backend.rs
Outdated
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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!
src/backend.rs
Outdated
|
|
||
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spurious indentation; either remove or run cargo fmt to auto-format your Rust code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed!
src/questions.rs
Outdated
| } 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.