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

Upgrading from 0.5.5 -> 0.5.9 causes proc macro panics. #1515

Closed
vgarleanu opened this issue Oct 26, 2021 · 6 comments
Closed

Upgrading from 0.5.5 -> 0.5.9 causes proc macro panics. #1515

vgarleanu opened this issue Oct 26, 2021 · 6 comments
Labels
db:sqlite Related to SQLite macros

Comments

@vgarleanu
Copy link

vgarleanu commented Oct 26, 2021

Hi, I've got queries like these that fail to compile:

SELECT id, library_id, name, description, rating, year, added, poster_path, backdrop_path, media_type as "media_type: _" 
FROM media 
WHERE library_id = ? AND NOT media_type = "episode"

The query proc macro seems to panic with the message:

error: proc macro panicked
  --> database/src/media.rs:59:12
   |
59 |   ...   Ok(sqlx::query_as!(
   |  __________^
60 | | ...           Media,
61 | | ...           r#"SELECT id, library_id, name, description, rating, year, added, poster_path, backdrop_path, media_type as "media_type: _"...
62 | | ...           library_id
63 | | ...       )
   | |___________^
   |
   = help: message: no entry found for key
   = note: this error originates in the macro `sqlx::query_as` (in Nightly builds, run with -Z macro-backtrace for more info)

These queries compile fine on 0.5.5 though.

@vgarleanu
Copy link
Author

vgarleanu commented Oct 26, 2021

The schema looks like this:

CREATE TABLE _tblmedia (
    id INTEGER NOT NULL,
    library_id INTEGER NOT NULL,

    name TEXT NOT NULL,
    description TEXT,
    rating INTEGER,
    year INTEGER,
    added TEXT,
    poster INTEGER,
    backdrop INTEGER,
    media_type TEXT NOT NULL,
    PRIMARY KEY (id),

    FOREIGN KEY (library_id) REFERENCES library(id) ON DELETE CASCADE,
    FOREIGN KEY (poster) REFERENCES assets(id),
    FOREIGN KEY (backdrop) REFERENCES assets(id)
);

-- Nicer view of media, ie we dont have to manually query some data.
CREATE VIEW media AS
SELECT _tblmedia.*, pp.local_path as poster_path, bp.local_path as backdrop_path
FROM _tblmedia
LEFT OUTER JOIN assets pp ON _tblmedia.poster = pp.id
LEFT OUTER JOIN assets bp ON _tblmedia.backdrop = bp.id;

I tried getting a backtrace of the proc-macro but it doesnt seem to show any meaningful information.

@abonander
Copy link
Collaborator

Try re-running cargo sqlx prepare?

@vgarleanu
Copy link
Author

Try re-running cargo sqlx prepare?

Same errors. Manually deleting sqlx-data.json and running cargo clean didn't change anything either.

@abonander
Copy link
Collaborator

@vgarleanu what database flavor is this? MySQL?

@vgarleanu
Copy link
Author

@vgarleanu what database flavor is this? MySQL?

The database flavor is sqlite.

@abonander
Copy link
Collaborator

I believe #1816 might have fixed this which is released as 0.6.0.

If anyone can reproduce this crash on 0.6.0, please feel free to open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
db:sqlite Related to SQLite macros
Projects
None yet
Development

No branches or pull requests

2 participants