MCPcopy Create free account
hub / github.com/hashintel/hash / to_sql

Method to_sql

libs/@local/hashql/eval/src/orchestrator/codec/encode/mod.rs:37–54  ·  view source on GitHub ↗
(
        &self,
        _: &postgres_types::Type,
        out: &mut BytesMut,
    )

Source from the content-addressed store, hash-verified

35
36 #[expect(clippy::cast_possible_truncation)]
37 fn to_sql(
38 &self,
39 _: &postgres_types::Type,
40 out: &mut BytesMut,
41 ) -> Result<postgres_types::IsNull, Box<dyn error::Error + Sync + Send>>
42 where
43 Self: Sized,
44 {
45 // The value has been determined via `Date.UTC(2000, 0, 1)` in JS, and is the same as the one that jdbc uses: https://jdbc.postgresql.org/documentation/publicapi/constant-values.html
46 const BASE: i128 = 946_684_800_000;
47
48 // Our timestamp is milliseconds since Unix epoch (1970-01-01).
49 // Postgres stores microseconds since 2000-01-01.
50 let value = ((Int::from(self.0).as_int() - BASE) * 1000) as i64;
51
52 postgres_protocol::types::timestamp_to_sql(value, out);
53 Ok(postgres_types::IsNull::No)
54 }
55}
56
57impl ToSql for Postgres<TemporalInterval> {

Calls 4

OkInterface · 0.85
fromFunction · 0.50
as_intMethod · 0.45
as_strMethod · 0.45