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

unsupported type NULL error only on my machine #3546

Open
tmvkrpxl0 opened this issue Oct 5, 2024 · 1 comment
Open

unsupported type NULL error only on my machine #3546

tmvkrpxl0 opened this issue Oct 5, 2024 · 1 comment
Labels

Comments

@tmvkrpxl0
Copy link

Bug Description

sqlx::query_file!("src/queries/leaderboard.sql") this has error:

unsupported type NULL of column #1 ("user")

the leaderboard.sql in question is:

select
	`user`,
	count(
		distinct date(`joined`, '+09:00')
	) as days,
	coalesce(
		sum(unixepoch(coalesce(`left`, 'now')) - unixepoch(`joined`)),
	0) as `total_duration`
from
	`vc_activities`
group by
	`user`
order by
	`total_duration` desc
limit 5

but this error does not happen on my friend's pc.

Minimal Reproduction

https://github.com/tmvkrpxl0/sqlx-report
I used sqlx-cli to setup database like this:

sqlx database create
sqlx migrate run

Then ran cargo build and got the same error

Info

  • SQLx version: 0.8.2, Both release on crate.io and git clone have this issue
  • SQLx features enabled: ["runtime-tokio", "sqlite"].
  • Database server and version: Me: (3.37.2), My friend: (3.46.1)
  • Operating system: Me: (KDE Neon 22.04), My friend: (Arch linux)
  • rustc --version: rustc 1.81.0
@tmvkrpxl0 tmvkrpxl0 added the bug label Oct 5, 2024
@rijkvp
Copy link

rijkvp commented Nov 10, 2024

I am getting the same error on a big aggregation query that also uses a GROUP BY statement (version 0.8.2). If I remove the GROUP BY there are no issues.

It seems like it incorrectly infers the type of the column to be NULL which is not supported by the compile-time verifier, as demonstrated by the following example:

use sqlx::SqliteConnection;

let mut conn = SqliteConnection::connect("sqlite::memory:").await.unwrap();
let res = sqlx::query!("SELECT NULL").fetch_one(&mut conn).await.unwrap(); // unsupported type NULL of column #1 ("NULL")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants