Skip to main content

MAX_SAFE_INTEGER

Constant MAX_SAFE_INTEGER 

Source
pub const MAX_SAFE_INTEGER: i64 = _; // 9_007_199_254_740_991i64
Expand description

Largest integer a JavaScript number (and so D1) represents exactly: 2^53 - 1.

D1 returns INTEGER columns as JavaScript numbers, so rows holding larger values cannot be read back into i64: validate input against this bound with Validator::safe_integer. Binding a larger i64 sends it as decimal text instead of a rounded number.

ยงExamples

use ocre::{IntoParam, MAX_SAFE_INTEGER};

assert_eq!(MAX_SAFE_INTEGER, 9_007_199_254_740_991);
let too_big = MAX_SAFE_INTEGER + 1;
assert_eq!(too_big.into_param(), too_big.to_string().into_param());