Trait diesel::pg::expression::extensions::DayAndMonthIntervalDsl
postgres
[] [src]

pub trait DayAndMonthIntervalDsl: Sized + Mul<Self, Output = Self> {
    fn days(self) -> PgInterval;
fn months(self) -> PgInterval; fn weeks(self) -> PgInterval { ... }
fn years(self) -> PgInterval { ... }
fn day(self) -> PgInterval { ... }
fn week(self) -> PgInterval { ... }
fn month(self) -> PgInterval { ... }
fn year(self) -> PgInterval { ... } }

A DSL added to i32 and f64 to construct PostgreSQL intervals of greater than 1 day.

The behavior of these methods when called on NAN or Infinity is undefined.

Example

connection.execute("INSERT INTO users (name, created_at) VALUES
    ('Sean', NOW()), ('Tess', NOW() - '5 days'::interval),
    ('Jim', NOW() - '10 days'::interval)").unwrap();

let mut data: Vec<String> = users
    .select(name)
    .filter(created_at.gt(now - 7.days()))
    .load(&connection).unwrap();
assert_eq!(2, data.len());
assert_eq!("Sean".to_string(), data[0]);
assert_eq!("Tess".to_string(), data[1]);

Required Methods

Returns a PgInterval representing self in days

Returns a PgInterval representing self in monhts

Provided Methods

Returns a PgInterval representing self in weeks

Note: When called on a high precision float, the returned interval may be 1 microsecond different than the equivalent string passed to PostgreSQL.

Returns a PgInterval representing self in weeks

Note: When called on a float, this method will mimic the behavior of PostgreSQL's interval parsing, and will ignore units smaller than months.

assert_eq!(1.08.years(), 1.year());
assert_eq!(1.09.years(), 1.year() + 1.month());

Identical to days

Identical to weeks

Identical to months

Identical to years

Implementations on Foreign Types

impl DayAndMonthIntervalDsl for i32
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

impl DayAndMonthIntervalDsl for f64
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

Implementors