Wrong type when mapping result rows using sea-query builder + sqlx

287 views Asked by At

I want to query a user from my users table of Postgres database.

...

// Build Query
let (sql, values) = Query::select()
    .columns([DbUser::Id, DbUser::Name, DbUser::Email])
    .from(DbUser::Table)
    .and_where(Expr::col(DbUser::Id).eq(user_id))
    .build(PostgresQueryBuilder);

// Execute query with sqlx
let result = bind_query(sqlx::query(&sql), &values)        
    .map(|row| {
      // I want to get access to my result values here
    })
    .fetch_optional(self.pool)
    .await?;
...

But unfortunately, it doesn't show the fields in the IntelliSense tooltip. See image below

But if I do the same request without sea-query using only sqlx it shows correct suggestion. See image below

I tried to follow this example from the official documentation.

What am I doing wrong?

1

There are 1 answers

0
Roman Mahotskyi On BEST ANSWER

I just added use sqlx::Row; to the top of the file and the issue disappeared.

I'm not sure what the "magic" behind this import is, but it works.

enter image description here