You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use pg_query;fnmain(){let simple = "SELECT * FROM x";let medium = "SELECT COUNT(1) AS count, name section FROM t GROUP BY name LIMIT 10";let complex = "SELECT country.country_name_eng, SUM(CASE WHEN talk.id IS NOT NULL THEN 1 ELSE 0 END) AS talks, AVG(ISNULL(DATEDIFF(SECOND, talk.start_time, talk.end_time),0)) AS avg_differenceFROM countryLEFT JOIN city ON city.country_id = country.idLEFT JOIN customer ON city.id = customer.city_idLEFT JOIN talk ON talk.customer_id = customer.idGROUP BY country.id, country.country_name_engHAVING AVG(ISNULL(DATEDIFF(SECOND, talk.start_time, talk.end_time),0)) > (SELECT AVG(DATEDIFF(SECOND, talk.start_time, talk.end_time)) FROM talk)ORDER BY talks DESC, country.id ASC;";let simplebad = "SELECT * FROM GROUP BY age";let tests = vec![simple, medium, complex, simplebad];for test in tests {match pg_query::parse(test){Ok(ast) => println!("AST: {:#?}", ast),Err(err) => println!("Error: {:#?}", err),}}}
But the above code won't compile now because ParsedQuery is not Debug:
$ cargo r
Compiling rust v0.1.0 (/Users/steve/Documents/workspace/rust)
error[E0277]: `pg_query::parse_result::ParseResult` doesn't implement `Debug` --> src/main.rs:30:47 |30 | Ok(ast) => println!("AST: {:#?}", ast), | ^^^ `pg_query::parse_result::ParseResult` cannot be formatted using `{:?}` because it doesn't implement `Debug`|
= help: the trait `Debug` is not implemented for`pg_query::parse_result::ParseResult`
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
For more information about this error, try `rustc --explain E0277`.
error: could not compile `rust` (bin "rust") due to 1 previous error
The text was updated successfully, but these errors were encountered:
This is probably a really stupid question, I am trying to print the parsed AST out, but the
ParsedQuery
type does not have eitherDebug
orDisplay
implemented, and, it is a private type so you cannot check its documentation, a post I found shows that it wasDebug
:But the above code won't compile now because
ParsedQuery
is notDebug
:The text was updated successfully, but these errors were encountered: