You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@age.apache.org by GitBox <gi...@apache.org> on 2021/12/20 04:23:13 UTC

[GitHub] [incubator-age] afidegnum edited a comment on issue #162: ANTLR, Can you explain the parsing workflow?

afidegnum edited a comment on issue #162:
URL: https://github.com/apache/incubator-age/issues/162#issuecomment-997583723


   This is my attempted implementation so far, which wasn't successful. I believe there is something I'm not properly addressing. 
   
   Cargo.toml
   ```
    . . . . 
   # [dependencies]
   rand = { version = "0.7.3" }
   tokio-postgres = { version = "0.5", features = ["with-chrono-0_4", "with-uuid-0_8"] }
   postgres-protocol = "*"
   postgres = "0.19.2"
   postgres-types = "*"
   
   ```
   src/main.rs
   
   ```rs
   struct AgType<'a>(&'a str);
   
   impl<'a> Display for AgType<'a>{
       
           fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
               let d: &str = self.0 ; 
               write!(f, "({})", d)
       }
   }
   
   impl<'a> FromSql<'a> for AgType<'a> {
       fn from_sql(_: &Type, raw: &'a [u8]) -> Result<AgType<'a>, Box<dyn Error + Sync + Send>> {
           let t = types::text_from_sql(raw)?;
           Ok(AgType(t))
       }
   
       fn accepts(ty: &Type) -> bool {
           ty.name() == "agtype"
       }
   }
   
   
   fn main(){
   
   pub fn graph_list() -> Result<(), Box<dyn Error>> {
       let conn_string = "host=localhost port=5432 dbname=texttest user=afidegnum password=chou1979";
       let mut client= Client::connect(conn_string, NoTls)?;
       
       &client
           .batch_execute("LOAD \'age\'")?;
   
       &client
           .batch_execute("SET search_path = ag_catalog, \"$user\", public")?;
   
        for row in &client.query("SELECT count(*) FROM ag_graph WHERE name= 'text_test'", &[])?{
            println!("{}", row.get::<_, i64>(0));
            let  count: i64 = row.get(0); println!("{}", count);
            println!("{}", count);
            dbg!(count);
        }
   
       
   
       for row in client.query("SELECT * from cypher('text_test', $$ MATCH (V:node) RETURN id(V) as vid $$) as (vid agtype)", &[])? {
           let path: AgType = row.get(0);
           println!("{}", path)
        }
       Ok(())
   }
   
   
   let res = graph_list();
   match res {
           Ok(r) => {println!("Succeeded! {:?} ", r);},
           Err(e) => {println!("Error: {}!", e);}
       }
   
   
   
   }
   ```
   ```
   1
   [src/lib.rs:20] count = 1
   1
   1
   Error: db error: ERROR: no binary output function available for type agtype!
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org