Skip to content
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

Add example for null value on INSERT #233

Open
erikschul opened this issue Jan 9, 2024 · 0 comments
Open

Add example for null value on INSERT #233

erikschul opened this issue Jan 9, 2024 · 0 comments

Comments

@erikschul
Copy link

erikschul commented Jan 9, 2024

Given the SQL

--! insert (a, b?)
INSERT INTO mytable (a,b)
VALUES (:a,:b);

Given the error

type annotations needed
cannot satisfy `_: cornucopia_async::StringSql`
the following types implement trait `cornucopia_async::StringSql`:
  std::boxed::Box<str>
  std::borrow::Cow<'_, str>
  std::string::String
  &T
  &str

It would be useful with an example of inserting a null value, using &None::<&str>, since &None and &None::<String> doesn't work.

cornucopia::queries::q::insert()
        .bind(&client, &"a", &None::<&str>)
        .await
        .unwrap();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant