Skip to content

Commit

Permalink
Julianday function and additional tests/comments
Browse files Browse the repository at this point in the history
  • Loading branch information
PThorpe92 committed Jan 3, 2025
1 parent 33532a0 commit 68b092c
Show file tree
Hide file tree
Showing 6 changed files with 289 additions and 311 deletions.
29 changes: 28 additions & 1 deletion COMPAT.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,38 @@ Feature support of [sqlite expr syntax](https://www.sqlite.org/lang_expr.html).
| date() | Yes | partially supports modifiers |
| time() | Yes | partially supports modifiers |
| datetime() | Yes | partially supports modifiers |
| julianday() | No | |
| julianday() | Partial | does not support modifiers |
| unixepoch() | Partial | does not support modifiers |
| strftime() | No | |
| timediff() | No | |

### Date and Time Modifiers
| Modifier | Status| Comment |
|----------------|-------|---------------------------------|
| Days | Yes | |
| Hours | Yes | |
| Minutes | Yes | |
| Seconds | Yes | |
| Months | Yes | |
| Years | Yes | |
| TimeOffset | Yes | |
| DateOffset | Yes | |
| DateTimeOffset | Yes | |
| Ceiling | No | |
| Floor | No | |
| StartOfMonth | Yes | |
| StartOfYear | Yes | |
| StartOfDay | Yes | |
| Weekday(N) | Yes | |
| Auto | No | |
| UnixEpoch | No | |
| JulianDay | No | |
| Localtime |Partial| requires fixes to avoid double conversions.|
| Utc |Partial| requires fixes to avoid double conversions.|
| Subsec | Yes | |



### JSON functions

| Function | Status | Comment |
Expand Down
3 changes: 3 additions & 0 deletions core/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ pub enum ScalarFunc {
Quote,
SqliteVersion,
UnixEpoch,
JulianDay,
Hex,
Unhex,
ZeroBlob,
Expand Down Expand Up @@ -152,6 +153,7 @@ impl Display for ScalarFunc {
Self::Unicode => "unicode".to_string(),
Self::Quote => "quote".to_string(),
Self::SqliteVersion => "sqlite_version".to_string(),
Self::JulianDay => "julianday".to_string(),
Self::UnixEpoch => "unixepoch".to_string(),
Self::Hex => "hex".to_string(),
Self::Unhex => "unhex".to_string(),
Expand Down Expand Up @@ -360,6 +362,7 @@ impl Func {
#[cfg(feature = "json")]
"json_array" => Ok(Self::Json(JsonFunc::JsonArray)),
"unixepoch" => Ok(Self::Scalar(ScalarFunc::UnixEpoch)),
"julianday" => Ok(Self::Scalar(ScalarFunc::JulianDay)),
"hex" => Ok(Self::Scalar(ScalarFunc::Hex)),
"unhex" => Ok(Self::Scalar(ScalarFunc::Unhex)),
"zeroblob" => Ok(Self::Scalar(ScalarFunc::ZeroBlob)),
Expand Down
4 changes: 2 additions & 2 deletions core/translate/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1450,11 +1450,11 @@ pub fn translate_expr(
});
Ok(target_register)
}
ScalarFunc::UnixEpoch => {
ScalarFunc::UnixEpoch | ScalarFunc::JulianDay => {
let mut start_reg = 0;
match args {
Some(args) if args.len() > 1 => {
crate::bail_parse_error!("epoch function with > 1 arguments. Modifiers are not yet supported.");
crate::bail_parse_error!("epoch or julianday function with > 1 arguments. Modifiers are not yet supported.");
}
Some(args) if args.len() == 1 => {
let arg_reg = program.alloc_register();
Expand Down
Loading

0 comments on commit 68b092c

Please sign in to comment.