Browse Source

may-minihttp use select * for db query (rust) (#6550)

Xudong Huang 4 years ago
parent
commit
b2857573ea
1 changed files with 4 additions and 6 deletions
  1. 4 6
      frameworks/Rust/may-minihttp/src/main.rs

+ 4 - 6
frameworks/Rust/may-minihttp/src/main.rs

@@ -86,11 +86,9 @@ struct PgConnection {
 impl PgConnection {
 impl PgConnection {
     fn new(db_url: &str) -> Self {
     fn new(db_url: &str) -> Self {
         let client = may_postgres::connect(db_url).unwrap();
         let client = may_postgres::connect(db_url).unwrap();
-        let world = client
-            .prepare("SELECT id, randomnumber FROM world WHERE id=$1")
-            .unwrap();
+        let world = client.prepare("SELECT * FROM world WHERE id=$1").unwrap();
 
 
-        let fortune = client.prepare("SELECT id, message FROM fortune").unwrap();
+        let fortune = client.prepare("SELECT * FROM fortune").unwrap();
 
 
         let mut updates = Vec::new();
         let mut updates = Vec::new();
         for num in 1..=500u16 {
         for num in 1..=500u16 {
@@ -198,8 +196,8 @@ impl PgConnection {
         Ok(worlds)
         Ok(worlds)
     }
     }
 
 
-    fn tell_fortune(&self) -> Result<SmallVec<[Fortune; 32]>, may_postgres::Error> {
-        let mut items: SmallVec<[_; 32]> = smallvec::smallvec![Fortune {
+    fn tell_fortune(&self) -> Result<Vec<Fortune>, may_postgres::Error> {
+        let mut items = vec![Fortune {
             id: 0,
             id: 0,
             message: Cow::Borrowed("Additional fortune added at request time."),
             message: Cow::Borrowed("Additional fortune added at request time."),
         }];
         }];