-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[hammerfest_store] Add
touch_theme_page
test
This commit uses a `sqlx` fork to use the fix from launchbadge/sqlx#1112.
- Loading branch information
Showing
8 changed files
with
178 additions
and
57 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
#[macro_use] | ||
pub mod types; | ||
|
||
#[cfg(feature = "sqlx")] | ||
mod pg_num; | ||
|
||
pub mod api; | ||
pub mod auth; | ||
pub mod clock; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use sqlx::{postgres, Postgres}; | ||
use std::convert::TryInto; | ||
use std::error::Error; | ||
|
||
#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq)] | ||
pub(crate) struct PgU8(u8); | ||
|
||
impl From<u8> for PgU8 { | ||
fn from(v: u8) -> Self { | ||
Self(v) | ||
} | ||
} | ||
|
||
impl From<PgU8> for u8 { | ||
fn from(v: PgU8) -> Self { | ||
v.0 | ||
} | ||
} | ||
|
||
#[cfg(feature = "sqlx")] | ||
impl sqlx::Type<Postgres> for PgU8 { | ||
fn type_info() -> postgres::PgTypeInfo { | ||
postgres::PgTypeInfo::with_name("u8") | ||
} | ||
|
||
fn compatible(ty: &postgres::PgTypeInfo) -> bool { | ||
*ty == Self::type_info() | ||
} | ||
} | ||
|
||
#[cfg(feature = "sqlx")] | ||
impl<'r> sqlx::Decode<'r, Postgres> for PgU8 { | ||
fn decode(value: postgres::PgValueRef<'r>) -> Result<Self, Box<dyn Error + 'static + Send + Sync>> { | ||
let v: i16 = <i16 as sqlx::Decode<Postgres>>::decode(value)?; | ||
let v: u8 = v.try_into().expect("invalid Postgres U8 value"); | ||
Ok(v.into()) | ||
} | ||
} | ||
|
||
#[cfg(feature = "sqlx")] | ||
impl<'q> sqlx::Encode<'q, Postgres> for PgU8 { | ||
fn encode_by_ref(&self, buf: &mut postgres::PgArgumentBuffer) -> sqlx::encode::IsNull { | ||
let v: i16 = u8::from(*self).into(); | ||
v.encode(buf) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.