-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: include custom sql type defs in schema.patch
- Loading branch information
1 parent
2ec4903
commit aeff9be
Showing
3 changed files
with
164 additions
and
17 deletions.
There are no files selected for viewing
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,18 +1,165 @@ | ||
135c135 | ||
< track -> Nullable<Array<Nullable<Position>>>, | ||
4,17c4,5 | ||
< //https://github.com/diesel-rs/diesel/blob/db6730c9a79135728ec4f87fabdb745d71cb4578/diesel_derives/src/sql_type.rs | ||
< use std::sync::atomic::{AtomicU32, Ordering}; | ||
< | ||
< use diesel::pg::PgTypeMetadata; | ||
< | ||
< pub static CUSTOM_TYPES: [&(&str, AtomicU32, AtomicU32); 6] = [ | ||
< &CARDIO_TYPE, | ||
< &DISTANCE_UNIT, | ||
< &METCON_TYPE, | ||
< &MOVEMENT_DIMENSION, | ||
< &POSITION, | ||
< &WEEKDAY, | ||
< ]; | ||
< | ||
--- | ||
> track -> Nullable<Array<Position>>, | ||
137c137 | ||
< cadence -> Nullable<Array<Nullable<Int4>>>, | ||
> #[derive(diesel::sql_types::SqlType)] | ||
> #[diesel(postgres_type(name = "cardio_type"))] | ||
20,37c8,9 | ||
< static CARDIO_TYPE: (&str, AtomicU32, AtomicU32) = | ||
< ("cardio_type", AtomicU32::new(0), AtomicU32::new(0)); | ||
< | ||
< impl diesel::sql_types::SqlType for CardioType { | ||
< type IsNull = diesel::sql_types::is_nullable::NotNull; | ||
< } | ||
< | ||
< impl diesel::sql_types::SingleValue for CardioType {} | ||
< | ||
< impl diesel::sql_types::HasSqlType<CardioType> for diesel::pg::Pg { | ||
< fn metadata(_: &mut Self::MetadataLookup) -> PgTypeMetadata { | ||
< PgTypeMetadata::new( | ||
< CARDIO_TYPE.1.load(Ordering::Acquire), | ||
< CARDIO_TYPE.2.load(Ordering::Acquire), | ||
< ) | ||
< } | ||
< } | ||
< | ||
--- | ||
> cadence -> Nullable<Array<Int4>>, | ||
139c139 | ||
< heart_rate -> Nullable<Array<Nullable<Int4>>>, | ||
> #[derive(diesel::sql_types::SqlType)] | ||
> #[diesel(postgres_type(name = "distance_unit"))] | ||
40,57c12,13 | ||
< static DISTANCE_UNIT: (&str, AtomicU32, AtomicU32) = | ||
< ("distance_unit", AtomicU32::new(0), AtomicU32::new(0)); | ||
< | ||
< impl diesel::sql_types::SqlType for DistanceUnit { | ||
< type IsNull = diesel::sql_types::is_nullable::NotNull; | ||
< } | ||
< | ||
< impl diesel::sql_types::SingleValue for DistanceUnit {} | ||
< | ||
< impl diesel::sql_types::HasSqlType<DistanceUnit> for diesel::pg::Pg { | ||
< fn metadata(_: &mut Self::MetadataLookup) -> PgTypeMetadata { | ||
< PgTypeMetadata::new( | ||
< DISTANCE_UNIT.1.load(Ordering::Acquire), | ||
< DISTANCE_UNIT.2.load(Ordering::Acquire), | ||
< ) | ||
< } | ||
< } | ||
< | ||
--- | ||
> heart_rate -> Nullable<Array<Int4>>, | ||
342,343c342,343 | ||
< track -> Nullable<Array<Nullable<Position>>>, | ||
< marked_positions -> Nullable<Array<Nullable<Position>>>, | ||
> #[derive(diesel::sql_types::SqlType)] | ||
> #[diesel(postgres_type(name = "metcon_type"))] | ||
60,77c16,17 | ||
< static METCON_TYPE: (&str, AtomicU32, AtomicU32) = | ||
< ("metcon_type", AtomicU32::new(0), AtomicU32::new(0)); | ||
< | ||
< impl diesel::sql_types::SqlType for MetconType { | ||
< type IsNull = diesel::sql_types::is_nullable::NotNull; | ||
< } | ||
< | ||
< impl diesel::sql_types::SingleValue for MetconType {} | ||
< | ||
< impl diesel::sql_types::HasSqlType<MetconType> for diesel::pg::Pg { | ||
< fn metadata(_: &mut Self::MetadataLookup) -> PgTypeMetadata { | ||
< PgTypeMetadata::new( | ||
< METCON_TYPE.1.load(Ordering::Acquire), | ||
< METCON_TYPE.2.load(Ordering::Acquire), | ||
< ) | ||
< } | ||
< } | ||
< | ||
--- | ||
> track -> Nullable<Array<Position>>, | ||
> marked_positions -> Nullable<Array<Position>>, | ||
> #[derive(diesel::sql_types::SqlType)] | ||
> #[diesel(postgres_type(name = "movement_dimension"))] | ||
80,97c20,21 | ||
< static MOVEMENT_DIMENSION: (&str, AtomicU32, AtomicU32) = | ||
< ("movement_dimension", AtomicU32::new(0), AtomicU32::new(0)); | ||
< | ||
< impl diesel::sql_types::SqlType for MovementDimension { | ||
< type IsNull = diesel::sql_types::is_nullable::NotNull; | ||
< } | ||
< | ||
< impl diesel::sql_types::SingleValue for MovementDimension {} | ||
< | ||
< impl diesel::sql_types::HasSqlType<MovementDimension> for diesel::pg::Pg { | ||
< fn metadata(_: &mut Self::MetadataLookup) -> PgTypeMetadata { | ||
< PgTypeMetadata::new( | ||
< MOVEMENT_DIMENSION.1.load(Ordering::Acquire), | ||
< MOVEMENT_DIMENSION.2.load(Ordering::Acquire), | ||
< ) | ||
< } | ||
< } | ||
< | ||
--- | ||
> #[derive(diesel::sql_types::SqlType)] | ||
> #[diesel(postgres_type(name = "position"))] | ||
100,117c24,25 | ||
< static POSITION: (&str, AtomicU32, AtomicU32) = | ||
< ("position", AtomicU32::new(0), AtomicU32::new(0)); | ||
< | ||
< impl diesel::sql_types::SqlType for Position { | ||
< type IsNull = diesel::sql_types::is_nullable::NotNull; | ||
< } | ||
< | ||
< impl diesel::sql_types::SingleValue for Position {} | ||
< | ||
< impl diesel::sql_types::HasSqlType<Position> for diesel::pg::Pg { | ||
< fn metadata(_: &mut Self::MetadataLookup) -> PgTypeMetadata { | ||
< PgTypeMetadata::new( | ||
< POSITION.1.load(Ordering::Acquire), | ||
< POSITION.2.load(Ordering::Acquire), | ||
< ) | ||
< } | ||
< } | ||
< | ||
--- | ||
> #[derive(diesel::sql_types::SqlType)] | ||
> #[diesel(postgres_type(name = "weekday"))] | ||
119,136d26 | ||
< | ||
< static WEEKDAY: (&str, AtomicU32, AtomicU32) = | ||
< ("weekday", AtomicU32::new(0), AtomicU32::new(0)); | ||
< | ||
< impl diesel::sql_types::SqlType for Weekday { | ||
< type IsNull = diesel::sql_types::is_nullable::NotNull; | ||
< } | ||
< | ||
< impl diesel::sql_types::SingleValue for Weekday {} | ||
< | ||
< impl diesel::sql_types::HasSqlType<Weekday> for diesel::pg::Pg { | ||
< fn metadata(_: &mut Self::MetadataLookup) -> PgTypeMetadata { | ||
< PgTypeMetadata::new( | ||
< WEEKDAY.1.load(Ordering::Acquire), | ||
< WEEKDAY.2.load(Ordering::Acquire), | ||
< ) | ||
< } | ||
< } | ||
219c109 | ||
< track -> Nullable<Array<Position>>, | ||
--- | ||
> track -> Nullable<Array<Nullable<Position>>>, | ||
221c111 | ||
< cadence -> Nullable<Array<Int4>>, | ||
--- | ||
> cadence -> Nullable<Array<Nullable<Int4>>>, | ||
223c113 | ||
< heart_rate -> Nullable<Array<Int4>>, | ||
--- | ||
> heart_rate -> Nullable<Array<Nullable<Int4>>>, | ||
414,415c304,305 | ||
< track -> Nullable<Array<Position>>, | ||
< marked_positions -> Nullable<Array<Position>>, | ||
--- | ||
> track -> Nullable<Array<Nullable<Position>>>, | ||
> marked_positions -> Nullable<Array<Nullable<Position>>>, |