~witcher/rss-email-devel

2 2

Compiling and reference DB

Details
Message ID
<20221120202822.qdvgbdnmr5yy4aoy@metal>
DKIM signature
pass
Download raw message
Hi,

I'm trying to build the latest version, but it's failing for me:

       Compiling rss-email v0.2.0 (/home/hugo/clones/git.sr.ht/~witcher/rss-email)
    error: failed to find data for query insert or ignore into posts (guid, title, author, url, feedurl, pub_date, content) values (?, ?, ?, ?, ?, ?, ?)
      --> src/db.rs:22:5
       |
    22 |     sqlx::query!("insert or ignore into posts (guid, title, author, url, feedurl, pub_date, content) values (?, ?, ?, ?, ?, ?, ?)", guid, title, author, url, feedurl, pub_date, content).ex...
       |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       |
       = note: this error originates in the macro `$crate::sqlx_macros::expand_query` which comes from the expansion of the macro `sqlx::query` (in Nightly builds, run with -Z macro-backtrace for more info)

    error: could not compile `rss-email` due to previous error

As far as I understand, sqlx will use a reference database to check that
queries are valid and compile them at compile time. So it seems that this
reference database is missing.

The part that really confuses me is: how are sourcehut builds working? I don't
see any indication to creating the reference database in the build manifest.

-- 
Hugo Osvaldo Barrera
Details
Message ID
<20221120203125.x2oou3rd5mt65tgx@metal>
In-Reply-To
<20221120202822.qdvgbdnmr5yy4aoy@metal> (view parent)
DKIM signature
pass
Download raw message
On 2022-11-20 21:28, Hugo Osvaldo Barrera wrote:
> 
> Hi,
> 
> I'm trying to build the latest version, but it's failing for me:
> 
>        Compiling rss-email v0.2.0 (/home/hugo/clones/git.sr.ht/~witcher/rss-email)
>     error: failed to find data for query insert or ignore into posts (guid, title, author, url, feedurl, pub_date, content) values (?, ?, ?, ?, ?, ?, ?)
>       --> src/db.rs:22:5
>        |
>     22 |     sqlx::query!("insert or ignore into posts (guid, title, author, url, feedurl, pub_date, content) values (?, ?, ?, ?, ?, ?, ?)", guid, title, author, url, feedurl, pub_date, content).ex...
>        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>        |
>        = note: this error originates in the macro `$crate::sqlx_macros::expand_query` which comes from the expansion of the macro `sqlx::query` (in Nightly builds, run with -Z macro-backtrace for more info)
> 
>     error: could not compile `rss-email` due to previous error
> 
> As far as I understand, sqlx will use a reference database to check that
> queries are valid and compile them at compile time. So it seems that this
> reference database is missing.
> 
> The part that really confuses me is: how are sourcehut builds working? I don't
> see any indication to creating the reference database in the build manifest.
> 
> -- 
> Hugo Osvaldo Barrera

Oh, never mind, I see that CI fails with the same issue... and that it's all
mentioned in the README.

-- 
Hugo Osvaldo Barrera
Details
Message ID
<20221120203806.o5mj7zw5m56tyxo7@navi>
In-Reply-To
<20221120202822.qdvgbdnmr5yy4aoy@metal> (view parent)
DKIM signature
pass
Download raw message
Hi,

On 20.11.22 09:28, Hugo Osvaldo Barrera wrote:
>As far as I understand, sqlx will use a reference database to check that
>queries are valid and compile them at compile time. So it seems that this
>reference database is missing.

Exactly. If you want to build for development, the README should
document everything you need for building:
https://git.sr.ht/~witcher/rss-email#compiling

The database can be created with `cargo sqlx database setup`, assuming
you have `sqlx-cli`[1] installed.
Checking queries at compile-time happens against a live database if the
`DATABASE_URL` environment variable is set. If it isn't set (or
`SQLX_OFFLINE` is set to `true`), it will use a generated JSON file
(that's the `sqlx-data.json` in the repo) generated with `cargo sqlx
prepare` and checked into git to check if the query is correct - this is
what happens in the CI.

You can read up on it here if you're interested:
https://github.com/launchbadge/sqlx/tree/main/sqlx-cli#sqlx-cli

I hope that clears it up a bit :)

[1]: https://github.com/launchbadge/sqlx/tree/main/sqlx-cli

Cheers,

-- 
witcher
Reply to thread Export thread (mbox)