pub enum EmbedRendering {
Verbatim,
Normalised,
}Expand description
How an embedded row or array is rendered.
jsonb reorders keys. It sorts them by length and then bytewise,
inside PostgreSQL – SELECT row_to_json(t)::jsonb FROM (SELECT 1 AS aaa, 2 AS zz) t gives {"zz": 2, "aaa": 1} – so the order the columns were
selected in is gone before the row reaches this process, and nothing on
the Rust side can put it back. It also regularises the spacing that json
keeps verbatim.
Both behaviours are wanted, in different places, which is why this is a choice made per query rather than a constant.
Variants§
Verbatim
json. The row is written exactly as row_to_json produced it, so the
columns stay in the order they were selected. This is what an embedded
resource in a JSON body wants, and what PostgREST itself emits there.
Normalised
jsonb. PostgreSQL normalises the text.
Only needed where the embedded value is rendered as text rather than
as part of a JSON body: a schema-declared media handler that
stringifies a whole row renders each column’s text, and a json column
renders verbatim where PostgREST’s jsonb one renders normalised –
{"id":1} against {"id": 1}. Measured: it is the only difference
between the two in PostgREST’s whole corpus.
Trait Implementations§
Source§impl Clone for EmbedRendering
impl Clone for EmbedRendering
impl Copy for EmbedRendering
Source§impl Debug for EmbedRendering
impl Debug for EmbedRendering
impl Eq for EmbedRendering
Source§impl PartialEq for EmbedRendering
impl PartialEq for EmbedRendering
impl StructuralPartialEq for EmbedRendering
Auto Trait Implementations§
impl Freeze for EmbedRendering
impl RefUnwindSafe for EmbedRendering
impl Send for EmbedRendering
impl Sync for EmbedRendering
impl Unpin for EmbedRendering
impl UnsafeUnpin for EmbedRendering
impl UnwindSafe for EmbedRendering
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more