Skip to content
Open
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 Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions crates/eql-scalars/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ impl ScalarKind {
self.as_bounded_int().is_some()
}

/// True for chrono-backed temporal kinds (`Date`; `Timestamptz` once added) —
/// the kinds whose test `ScalarType` impl is generated by `temporal_values!`
/// rather than the integer proc-macro path. Replaces the `[temporal]` marker.
pub const fn is_temporal(self) -> bool {
matches!(self, ScalarKind::Date)
}

/// The Rust type name as it appears in generated source (e.g. `"i32"`).
pub const fn rust_type(self) -> &'static str {
match self {
Expand Down Expand Up @@ -360,6 +367,14 @@ impl ScalarSpec {
pub fn domain_name(&self, domain: &DomainSpec) -> String {
format!("{}{}", self.token, domain.suffix)
}

/// True when this type declares no ordered (`_ord`) domain — i.e. equality-only
/// (storage + `_eq`). Replaces the future `[eq_only]` marker: the domain set
/// already carries this. The `_ord_ore` twin only appears alongside `_ord`, so
/// testing `_ord` suffices.
pub fn is_eq_only(&self) -> bool {
!self.domains.iter().any(|d| d.suffix == "_ord")
}
}

/// Domains shared by every ordered-integer scalar, in manifest file order:
Expand Down Expand Up @@ -650,6 +665,23 @@ mod rust_tests {
}
}
}

#[test]
fn is_temporal_classifies_chrono_kinds() {
assert!(ScalarKind::Date.is_temporal());
assert!(!ScalarKind::I16.is_temporal());
assert!(!ScalarKind::I32.is_temporal());
assert!(!ScalarKind::I64.is_temporal());
// Timestamptz arrives in Phase 5; assert it here once present.
}

#[test]
fn is_eq_only_detects_absence_of_ord_domains() {
let int4 = CATALOG.iter().find(|s| s.token == "int4").unwrap();
assert!(!int4.is_eq_only(), "int4 is ordered");
let date = CATALOG.iter().find(|s| s.token == "date").unwrap();
assert!(!date.is_eq_only(), "date is ordered");
}
}

#[cfg(test)]
Expand Down
1 change: 1 addition & 0 deletions crates/eql-tests-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ proc-macro = true
syn = { version = "2", features = ["full"] }
quote = "1"
proc-macro2 = "1"
eql-scalars = { path = "../eql-scalars" }
Loading