Open JaydenElliott opened 1 year ago
I also run into the same problem. However, the error only shows up on rust-analyzer (2023-03-13)
. My rustc (rustc 1.67.0-nightly (edf018221 2022-11-02)
) would happily compiles the code.
Getting the same error when running the sqlite/todos
example with SQLx version 0.6.2. It also seems to be relevant only for rust-analyzer, since cargo check
and clippy
do not complain.
Same error.
Minimal Reproduction
CREATE TABLE
public.articles (
id serial NOT NULL,
created_at timestamp without time zone NOT NULL DEFAULT now(),
title character varying(255) NOT NULL,
content text NOT NULL,
date date NOT NULL DEFAULT CURRENT_DATE
);
ALTER TABLE
public.articles
ADD
CONSTRAINT articles_pkey PRIMARY KEY (id)
create sequence
blog_id_seq
increment 1
minvalue 1
maxvalue 9223372036854775807
start with 1
cache 1
insert into "public"."articles" ("content", "created_at", "date", "id", "title") values ('Hello everyone', '2023-03-16 17:42:45.071063', '2023-03-16', 2, 'Welcom');
/// get one article per id
pub async fn get_article(
id: Path<(u32,)>,
state: State<Arc<AppState>>,
) -> Result<Json<Article>, CustomError> {
let db_pool = &state.db_pool;
let article = sqlx::query!(
"SELECT title, content, date FROM articles WHERE id = $1",
id.0 as i32
)
.fetch_one(db_pool)
.await?;
let article = Article{
id: None,
title: article.title.clone(),
content: article.content.clone(),
date: Some(article.date),
};
Ok(Json(article))
}
Info
SQLx version: 0.6.2 SQLx features enabled: ["runtime-tokio-rustls", "postgres", "macros" , "chrono"] Database server and version: Postgres 15.2 Operating system: macOS 12.6.1 rustc --version: 1.70.0 nightly
Bug Description
When attempting to use
query!
withmap
, I cannot get any of the rows out of the record and receive the errorfield "mood" of "Record" is private
The strange thing this is that when doing this in a test environment with
#[sqlx::test]
the error disappears.Minimal Reproduction
With the following table
and query
Info
rustc --version
: 1.67.1