prisma / quaint

SQL Query AST and Visitor for Rust
Apache License 2.0
582 stars 62 forks source link

Cannot compile master #207

Closed maxnachlinger closed 4 years ago

maxnachlinger commented 4 years ago

Hey awesome quaint maintainers :) I'm getting this error when attempting to compile quaint:

   Compiling quaint v0.2.0-alpha.13 (https://github.com/prisma/quaint.git#03a6d66d)
error[E0201]: duplicate definitions with name `visit_not_equals`:
   --> /Users/Max/.cargo/git/checkouts/quaint-9f01e008b9a89c14/03a6d66/src/visitor/postgres.rs:258:5
    |
230 | /     fn visit_not_equals(&mut self, left: Expression<'a>, right: Expression<'a>) -> visitor::Result {
231 | |         // LHS must be cast to json/xml-text if the right is a json/xml-text value and vice versa.
232 | |         let right_cast = match left {
233 | |             #[cfg(feature = "json-1")]
...   |
254 | |         Ok(())
255 | |     }
    | |_____- previous definition of `visit_not_equals` here
...
258 | /     fn visit_not_equals(&mut self, left: Expression<'a>, right: Expression<'a>) -> visitor::Result {
259 | |         self.visit_expression(left)?;
260 | |         self.write(" <> ")?;
261 | |         self.visit_expression(right)
262 | |     }
    | |_____^ duplicate definition

error: aborting due to previous error

In case it helps, here are my cargo dependencies:

[dependencies]
tokio = { version = "0.2", features = ["full"]}
quaint = { git = "https://github.com/prisma/quaint.git", features = ["full-mssql"]}

and here's my silly test main.rs:

use quaint::{prelude::*, pooled::Quaint};

// assuming a local mssql instance started via:
// docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<YourStrong@Passw0rd>' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2017-latest

#[tokio::main]
async fn main() -> Result<(), quaint::error::Error> {
    let dsn = "sqlserver://127.0.0.1:1433;database=master;user=SA;password=<YourStrong@Passw0rd>;trustServerCertificate=true;encrypt=DANGER_PLAINTEXT";
    let pool = Quaint::builder(dsn)?.build();
    let conn = pool.check_out().await?;
    let result = conn.select(Select::default().value(1)).await?;

    assert_eq!(
        Some(1),
        result.into_iter().nth(0).and_then(|row| row[0].as_i64()),
    );

    Ok(())
}
maxnachlinger commented 4 years ago

This may well be a local issue, but I'm getting this from the new fix-mssql-compilation branch: My cargo file deps:

[dependencies]
tokio = { version = "0.2", features = ["full"]}
quaint = { git = "https://github.com/prisma/quaint.git", branch = "fix-mssql-compilation", features = ["full-mssql"]}

and the error:

error[E0432]: unresolved import `quaint::pooled`
 --> src/main.rs:1:26
  |
1 | use quaint::{prelude::*, pooled::Quaint};
  |                          ^^^^^^ could not find `pooled` in `quaint`
maxnachlinger commented 4 years ago

Looks like master is still unhappy when compiling with the full-mssql feature turned on. Here's the failing Travis build and here's the silly test project. I'm still quite new to Rust but plan on taking a crack at these errors to see if I can help :) Edit: I'll open a new issue for this