You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using sqlx and a sqlite DB that has a column id text not null that contains (hyphenated) uuids.
My struct derives FromRow and has the macro #[sqlx(try_from = "Hyphenated")] for its id field, declared as uuid.Uuid.
select_as!(mytype, ..) fails at compile time if it's just a Select id from .. with "Expected Uuid, found String" (so try_from doesn't seem to do anything there). Changing this statement to Select id as "id: uuid.Uuid" from .. fails at runtime, because that expects a binary (16 byte) representation of the uuid, not my hyphenated text. Again, try_from doesn't seem to do anything. What am I missing?
I even tried Select id as "id: Hyphenated" from .. .. but that then informs me that it expected a Uuid, found a Hyphenated and that I should try an .into() ... which is what I'm trying to achieve of course.
TL/DR: I know Sqlite doesn't support Uuid values at the DB level. In spite of that, how can I serialize Uuids to Sqlite (as Text ideally) and deserialize them (into proper Uuid values, not a String)?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am using sqlx and a sqlite DB that has a column
id text not null
that contains (hyphenated) uuids.My struct derives
FromRow
and has the macro#[sqlx(try_from = "Hyphenated")]
for itsid
field, declared asuuid.Uuid
.select_as!(mytype, ..)
fails at compile time if it's just aSelect id from ..
with "Expected Uuid, found String" (sotry_from
doesn't seem to do anything there). Changing this statement toSelect id as "id: uuid.Uuid" from ..
fails at runtime, because that expects a binary (16 byte) representation of the uuid, not my hyphenated text. Again,try_from
doesn't seem to do anything. What am I missing?I even tried
Select id as "id: Hyphenated" from ..
.. but that then informs me that it expected a Uuid, found a Hyphenated and that I should try an.into()
... which is what I'm trying to achieve of course.TL/DR: I know Sqlite doesn't support Uuid values at the DB level. In spite of that, how can I serialize Uuids to Sqlite (as Text ideally) and deserialize them (into proper Uuid values, not a String)?
Beta Was this translation helpful? Give feedback.
All reactions