Skip to content

Commit

Permalink
Add DateTime func and support more modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
PThorpe92 committed Jan 3, 2025
1 parent 90d01f4 commit 7818e35
Show file tree
Hide file tree
Showing 5 changed files with 772 additions and 97 deletions.
2 changes: 1 addition & 1 deletion COMPAT.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ Feature support of [sqlite expr syntax](https://www.sqlite.org/lang_expr.html).
|-------------|---------|------------------------------|
| date() | Yes | partially supports modifiers |
| time() | Yes | partially supports modifiers |
| datetime() | No | |
| datetime() | Yes | partially supports modifiers |
| julianday() | No | |
| unixepoch() | Partial | does not support modifiers |
| strftime() | No | |
Expand Down
3 changes: 3 additions & 0 deletions core/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ pub enum ScalarFunc {
Soundex,
Date,
Time,
DateTime,
Typeof,
Unicode,
Quote,
Expand Down Expand Up @@ -157,6 +158,7 @@ impl Display for ScalarFunc {
Self::ZeroBlob => "zeroblob".to_string(),
Self::LastInsertRowid => "last_insert_rowid".to_string(),
Self::Replace => "replace".to_string(),
Self::DateTime => "datetime".to_string(),
};
write!(f, "{}", str)
}
Expand Down Expand Up @@ -344,6 +346,7 @@ impl Func {
"substring" => Ok(Self::Scalar(ScalarFunc::Substring)),
"date" => Ok(Self::Scalar(ScalarFunc::Date)),
"time" => Ok(Self::Scalar(ScalarFunc::Time)),
"datetime" => Ok(Self::Scalar(ScalarFunc::DateTime)),
"typeof" => Ok(Self::Scalar(ScalarFunc::Typeof)),
"last_insert_rowid" => Ok(Self::Scalar(ScalarFunc::LastInsertRowid)),
"unicode" => Ok(Self::Scalar(ScalarFunc::Unicode)),
Expand Down
2 changes: 1 addition & 1 deletion core/translate/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,7 @@ pub fn translate_expr(
});
Ok(target_register)
}
ScalarFunc::Date => {
ScalarFunc::Date | ScalarFunc::DateTime => {
if let Some(args) = args {
for arg in args.iter() {
// register containing result of each argument expression
Expand Down
Loading

0 comments on commit 7818e35

Please sign in to comment.