Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address recent lints #1714

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pgrx-tests/src/tests/cfg_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//LICENSE All rights reserved.
//LICENSE
//LICENSE Use of this source code is governed by the MIT license that can be found in the LICENSE file.
#![allow(unexpected_cfgs)]
use pgrx::prelude::*;

#[cfg(any(test, feature = "pg_test"))]
Expand Down
8 changes: 4 additions & 4 deletions pgrx-version-updater/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::io::{BufRead, Write};
use std::path::Path;
use std::process::{Command, Stdio};
use std::{env, path::PathBuf};
use toml_edit::{value, Document, Entry, Item};
use toml_edit::{value, DocumentMut, Entry, Item};
use walkdir::{DirEntry, WalkDir};

#[derive(Parser)]
Expand Down Expand Up @@ -118,7 +118,7 @@ fn query_toml(query_args: &QueryCargoVersionArgs) {
let data = fs::read_to_string(&filepath)
.expect(format!("Unable to open file at {}", filepath.display()).as_str());

let doc = data.parse::<Document>().expect(
let doc = data.parse::<DocumentMut>().expect(
format!("File at location {} is an invalid Cargo.toml file", filepath.display()).as_str(),
);

Expand Down Expand Up @@ -254,7 +254,7 @@ fn update_files(args: &UpdateFilesArgs) {
let data = fs::read_to_string(&filepath)
.expect(format!("Unable to open file at {}", filepath.display()).as_str());

let mut doc = data.parse::<Document>().expect(
let mut doc = data.parse::<DocumentMut>().expect(
format!("File at location {} is an invalid Cargo.toml file", filepath.display())
.as_str(),
);
Expand Down Expand Up @@ -459,7 +459,7 @@ fn extract_package_name<P: AsRef<Path>>(filepath: P) -> Option<String> {
let data = fs::read_to_string(filepath)
.expect(format!("Unable to open file at {}", filepath.display()).as_str());

let doc = data.parse::<Document>().expect(
let doc = data.parse::<DocumentMut>().expect(
format!("File at location {} is an invalid Cargo.toml file", filepath.display()).as_str(),
);

Expand Down
44 changes: 0 additions & 44 deletions pgrx/src/datum/datetime_support/ctor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,47 +85,3 @@ pub fn to_timestamp(epoch_seconds: f64) -> TimestampWithTimeZone {
direct_function_call(pg_sys::float8_timestamptz, &[epoch_seconds.into_datum()]).unwrap()
}
}

/// “bins” the input timestamp into the specified interval (the stride) aligned with a specified origin.
///
/// `source` is a value expression of type [`Timestamp`].
/// `stride` is a value expression of type [`Interval`].
///
/// The return value is likewise of type [`Timestamp`], and it marks the beginning of the bin into
/// which the source is placed.
///
/// # Notes
///
/// Only available on Postgres v14 and greater.
///
/// In the case of full units (1 minute, 1 hour, etc.), it gives the same result as the analogous
/// `date_trunc()` function, but the difference is that [`date_bin()`] can truncate to an arbitrary
/// interval.
///
/// The stride interval must be greater than zero and cannot contain units of month or larger.
///
/// # Examples
///
/// ```sql
/// SELECT date_bin('15 minutes', TIMESTAMP '2020-02-11 15:44:17', TIMESTAMP '2001-01-01');
/// Result: 2020-02-11 15:30:00
///
/// SELECT date_bin('15 minutes', TIMESTAMP '2020-02-11 15:44:17', TIMESTAMP '2001-01-01 00:02:30');
/// Result: 2020-02-11 15:32:30
/// ```
///
/// TODO: See https://github.com/pgcentralfoundation/pgrx/pull/1414
#[cfg(any(features = "pg14", features = "pg15"))]
pub fn date_bin(
stride: crate::datum::interval::Interval,
source: Timestamp,
origin: Timestamp,
) -> Timestamp {
unsafe {
direct_function_call(
pg_sys::date_bin,
&[stride.into_datum(), source.into_datum(), origin.into_datum()],
)
.unwrap()
}
}
Loading