Skip to content

query_file_as doesn't pick up .sql changes #663

Closed

Description

@leebenson

I'm not sure if this is something that sqlx is best placed to solve, or whether this is more the domain of cargo, but I noticed that changes to .sql files referenced in query_as_file! aren't picked up in subsequent cargo operations.

This can lead to some subtle bugs where a query did work, but was since changed and not picked up in the next build.

Curious if there's a recommended approach to solving this. Thanks!

Activity

  1. abonander commented on Aug 30, 2020

    @abonander
    Collaborator

    We need to emit include_str!() from the macro so the compiler knows to watch the file for changes. The slightly difficult part is that query_file_as!() and include_str!() resolve file paths from different locations, but I think we can just canonicalize the file path and emit it as absolute.

    That's normally an anti-pattern as it makes the project not-portable to other machines but since we're canonicalizing on the fly it should be fine.

  2. added
    help wanted
    on Sep 2, 2020
  3. Freax13 commented on Feb 2, 2021

    @Freax13
    Contributor

    The same should apply to sqlx-data.json, shouldn't it?

  4. jplatte commented on Feb 2, 2021

    @jplatte
    Contributor

    @Freax13 This seems like a very rare edge case but I think you're right. I'd wouldn't recommend working on that though, I'm currently working on #941 to hopefully get that into 0.5.

  5. Freax13 commented on Feb 2, 2021

    @Freax13
    Contributor

    @jplatte ok, that's great 👍

  6. added 6 commits that reference this issue on Jul 20, 2021
    39124c5
    ee2b14e
    6fe2cca
    33c3ec4
    edb6b5f
    e1f9b51
  7. added a commit that references this issue on Jul 21, 2021
    e89cb09
  8. added 2 commits that reference this issue on Nov 19, 2021
    6cdb35d
    b5a95c4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-easyhelp wantedmacros

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions