Use of skip or default with query_as!
macro?
#3074
Replies: 3 comments 1 reply
-
I'm also running into this issue, I have a hunch that it may have to do with the order in which the macros run. Commenting here to follow the issue and will report back if I find something. EDIT: just found this. It looks like currently the |
Beta Was this translation helpful? Give feedback.
-
Have you found any workaround that doesn't imply creating a second, slightly different struct? I just ran into this same problem. |
Beta Was this translation helpful? Give feedback.
-
I would appreciate this too! |
Beta Was this translation helpful? Give feedback.
-
Hi there,
I want a struct to allow for nested data, but the field doesn't exist in the database. I can't seem to use
#[sqlx(skip)]
and ignore that field withquery_as!
.I have read through the docs and FAQ, but am not finding anything.
is there a way to tell sqlx that the field is not expected to be in the database?
This gives me:
I still want the benefit of static checking, but would like to avoid creating duplicate types with slight variations. As a workaround I have created 2 structs. One as the database response type without the additional field, which I then copy over to the 2nd type which does have that field.
I'm new to sqlx so any suggestions on best practices would be appreciated.
Beta Was this translation helpful? Give feedback.
All reactions