mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-02 06:44:23 +01:00
Run formatting and enforce formatting in CI
This commit is contained in:
6
.github/workflows/rust.yml
vendored
6
.github/workflows/rust.yml
vendored
@@ -10,6 +10,12 @@ env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
cargo-fmt-check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Check formatting
|
||||
run: cargo fmt --check
|
||||
build-native:
|
||||
strategy:
|
||||
matrix:
|
||||
|
||||
264
core/datetime.rs
264
core/datetime.rs
@@ -247,74 +247,198 @@ mod tests {
|
||||
|
||||
let test_cases = [
|
||||
// Format 1: YYYY-MM-DD (no timezone applicable)
|
||||
(OwnedValue::Text(Rc::new("2024-07-21".to_string())), test_date_str),
|
||||
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21".to_string())),
|
||||
test_date_str,
|
||||
),
|
||||
// Format 2: YYYY-MM-DD HH:MM
|
||||
(OwnedValue::Text(Rc::new("2024-07-21 22:30".to_string())), test_date_str),
|
||||
(OwnedValue::Text(Rc::new("2024-07-21 22:30+02:00".to_string())), test_date_str),
|
||||
(OwnedValue::Text(Rc::new("2024-07-21 22:30-05:00".to_string())), next_date_str),
|
||||
(OwnedValue::Text(Rc::new("2024-07-21 01:30+05:00".to_string())), prev_date_str),
|
||||
(OwnedValue::Text(Rc::new("2024-07-21 22:30Z".to_string())), test_date_str),
|
||||
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21 22:30".to_string())),
|
||||
test_date_str,
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21 22:30+02:00".to_string())),
|
||||
test_date_str,
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21 22:30-05:00".to_string())),
|
||||
next_date_str,
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21 01:30+05:00".to_string())),
|
||||
prev_date_str,
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21 22:30Z".to_string())),
|
||||
test_date_str,
|
||||
),
|
||||
// Format 3: YYYY-MM-DD HH:MM:SS
|
||||
(OwnedValue::Text(Rc::new("2024-07-21 22:30:45".to_string())), test_date_str),
|
||||
(OwnedValue::Text(Rc::new("2024-07-21 22:30:45+02:00".to_string())), test_date_str),
|
||||
(OwnedValue::Text(Rc::new("2024-07-21 22:30:45-05:00".to_string())), next_date_str),
|
||||
(OwnedValue::Text(Rc::new("2024-07-21 01:30:45+05:00".to_string())), prev_date_str),
|
||||
(OwnedValue::Text(Rc::new("2024-07-21 22:30:45Z".to_string())), test_date_str),
|
||||
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21 22:30:45".to_string())),
|
||||
test_date_str,
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21 22:30:45+02:00".to_string())),
|
||||
test_date_str,
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21 22:30:45-05:00".to_string())),
|
||||
next_date_str,
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21 01:30:45+05:00".to_string())),
|
||||
prev_date_str,
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21 22:30:45Z".to_string())),
|
||||
test_date_str,
|
||||
),
|
||||
// Format 4: YYYY-MM-DD HH:MM:SS.SSS
|
||||
(OwnedValue::Text(Rc::new("2024-07-21 22:30:45.123".to_string())), test_date_str),
|
||||
(OwnedValue::Text(Rc::new("2024-07-21 22:30:45.123+02:00".to_string())), test_date_str),
|
||||
(OwnedValue::Text(Rc::new("2024-07-21 22:30:45.123-05:00".to_string())), next_date_str),
|
||||
(OwnedValue::Text(Rc::new("2024-07-21 01:30:45.123+05:00".to_string())), prev_date_str),
|
||||
(OwnedValue::Text(Rc::new("2024-07-21 22:30:45.123Z".to_string())), test_date_str),
|
||||
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21 22:30:45.123".to_string())),
|
||||
test_date_str,
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21 22:30:45.123+02:00".to_string())),
|
||||
test_date_str,
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21 22:30:45.123-05:00".to_string())),
|
||||
next_date_str,
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21 01:30:45.123+05:00".to_string())),
|
||||
prev_date_str,
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21 22:30:45.123Z".to_string())),
|
||||
test_date_str,
|
||||
),
|
||||
// Format 5: YYYY-MM-DDTHH:MM
|
||||
(OwnedValue::Text(Rc::new("2024-07-21T22:30".to_string())), test_date_str),
|
||||
(OwnedValue::Text(Rc::new("2024-07-21T22:30+02:00".to_string())), test_date_str),
|
||||
(OwnedValue::Text(Rc::new("2024-07-21T22:30-05:00".to_string())), next_date_str),
|
||||
(OwnedValue::Text(Rc::new("2024-07-21T01:30+05:00".to_string())), prev_date_str),
|
||||
(OwnedValue::Text(Rc::new("2024-07-21T22:30Z".to_string())), test_date_str),
|
||||
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21T22:30".to_string())),
|
||||
test_date_str,
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21T22:30+02:00".to_string())),
|
||||
test_date_str,
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21T22:30-05:00".to_string())),
|
||||
next_date_str,
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21T01:30+05:00".to_string())),
|
||||
prev_date_str,
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21T22:30Z".to_string())),
|
||||
test_date_str,
|
||||
),
|
||||
// Format 6: YYYY-MM-DDTHH:MM:SS
|
||||
(OwnedValue::Text(Rc::new("2024-07-21T22:30:45".to_string())), test_date_str),
|
||||
(OwnedValue::Text(Rc::new("2024-07-21T22:30:45+02:00".to_string())), test_date_str),
|
||||
(OwnedValue::Text(Rc::new("2024-07-21T22:30:45-05:00".to_string())), next_date_str),
|
||||
(OwnedValue::Text(Rc::new("2024-07-21T01:30:45+05:00".to_string())), prev_date_str),
|
||||
(OwnedValue::Text(Rc::new("2024-07-21T22:30:45Z".to_string())), test_date_str),
|
||||
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21T22:30:45".to_string())),
|
||||
test_date_str,
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21T22:30:45+02:00".to_string())),
|
||||
test_date_str,
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21T22:30:45-05:00".to_string())),
|
||||
next_date_str,
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21T01:30:45+05:00".to_string())),
|
||||
prev_date_str,
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21T22:30:45Z".to_string())),
|
||||
test_date_str,
|
||||
),
|
||||
// Format 7: YYYY-MM-DDTHH:MM:SS.SSS
|
||||
(OwnedValue::Text(Rc::new("2024-07-21T22:30:45.123".to_string())), test_date_str),
|
||||
(OwnedValue::Text(Rc::new("2024-07-21T22:30:45.123+02:00".to_string())), test_date_str),
|
||||
(OwnedValue::Text(Rc::new("2024-07-21T22:30:45.123-05:00".to_string())), next_date_str),
|
||||
(OwnedValue::Text(Rc::new("2024-07-21T01:30:45.123+05:00".to_string())), prev_date_str),
|
||||
(OwnedValue::Text(Rc::new("2024-07-21T22:30:45.123Z".to_string())), test_date_str),
|
||||
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21T22:30:45.123".to_string())),
|
||||
test_date_str,
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21T22:30:45.123+02:00".to_string())),
|
||||
test_date_str,
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21T22:30:45.123-05:00".to_string())),
|
||||
next_date_str,
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21T01:30:45.123+05:00".to_string())),
|
||||
prev_date_str,
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("2024-07-21T22:30:45.123Z".to_string())),
|
||||
test_date_str,
|
||||
),
|
||||
// Format 8: HH:MM
|
||||
(OwnedValue::Text(Rc::new("22:30".to_string())), "2000-01-01"),
|
||||
(OwnedValue::Text(Rc::new("22:30+02:00".to_string())), "2000-01-01"),
|
||||
(OwnedValue::Text(Rc::new("22:30-05:00".to_string())), "2000-01-02"),
|
||||
(OwnedValue::Text(Rc::new("01:30+05:00".to_string())), "1999-12-31"),
|
||||
(OwnedValue::Text(Rc::new("22:30Z".to_string())), "2000-01-01"),
|
||||
|
||||
(
|
||||
OwnedValue::Text(Rc::new("22:30+02:00".to_string())),
|
||||
"2000-01-01",
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("22:30-05:00".to_string())),
|
||||
"2000-01-02",
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("01:30+05:00".to_string())),
|
||||
"1999-12-31",
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("22:30Z".to_string())),
|
||||
"2000-01-01",
|
||||
),
|
||||
// Format 9: HH:MM:SS
|
||||
(OwnedValue::Text(Rc::new("22:30:45".to_string())), "2000-01-01"),
|
||||
(OwnedValue::Text(Rc::new("22:30:45+02:00".to_string())), "2000-01-01"),
|
||||
(OwnedValue::Text(Rc::new("22:30:45-05:00".to_string())), "2000-01-02"),
|
||||
(OwnedValue::Text(Rc::new("01:30:45+05:00".to_string())), "1999-12-31"),
|
||||
(OwnedValue::Text(Rc::new("22:30:45Z".to_string())), "2000-01-01"),
|
||||
|
||||
(
|
||||
OwnedValue::Text(Rc::new("22:30:45".to_string())),
|
||||
"2000-01-01",
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("22:30:45+02:00".to_string())),
|
||||
"2000-01-01",
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("22:30:45-05:00".to_string())),
|
||||
"2000-01-02",
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("01:30:45+05:00".to_string())),
|
||||
"1999-12-31",
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("22:30:45Z".to_string())),
|
||||
"2000-01-01",
|
||||
),
|
||||
// Format 10: HH:MM:SS.SSS
|
||||
(OwnedValue::Text(Rc::new("22:30:45.123".to_string())), "2000-01-01"),
|
||||
(OwnedValue::Text(Rc::new("22:30:45.123+02:00".to_string())), "2000-01-01"),
|
||||
(OwnedValue::Text(Rc::new("22:30:45.123-05:00".to_string())), "2000-01-02"),
|
||||
(OwnedValue::Text(Rc::new("01:30:45.123+05:00".to_string())), "1999-12-31"),
|
||||
(OwnedValue::Text(Rc::new("22:30:45.123Z".to_string())), "2000-01-01"),
|
||||
|
||||
(
|
||||
OwnedValue::Text(Rc::new("22:30:45.123".to_string())),
|
||||
"2000-01-01",
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("22:30:45.123+02:00".to_string())),
|
||||
"2000-01-01",
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("22:30:45.123-05:00".to_string())),
|
||||
"2000-01-02",
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("01:30:45.123+05:00".to_string())),
|
||||
"1999-12-31",
|
||||
),
|
||||
(
|
||||
OwnedValue::Text(Rc::new("22:30:45.123Z".to_string())),
|
||||
"2000-01-01",
|
||||
),
|
||||
// Test Format 11: 'now'
|
||||
(OwnedValue::Text(Rc::new("now".to_string())), &now),
|
||||
|
||||
// Format 12: DDDDDDDDDD (Julian date as float or integer)
|
||||
(OwnedValue::Float(2460512.5), test_date_str),
|
||||
(OwnedValue::Integer(2460513), test_date_str),
|
||||
@@ -333,13 +457,13 @@ mod tests {
|
||||
#[test]
|
||||
fn test_invalid_get_date_from_time_value() {
|
||||
let invalid_cases = [
|
||||
OwnedValue::Text(Rc::new("2024-07-21 25:00".to_string())), // Invalid hour
|
||||
OwnedValue::Text(Rc::new("2024-07-21 24:00:00".to_string())), // Invalid hour
|
||||
OwnedValue::Text(Rc::new("2024-07-21 23:60:00".to_string())), // Invalid minute
|
||||
OwnedValue::Text(Rc::new("2024-07-21 22:58:60".to_string())), // Invalid second
|
||||
OwnedValue::Text(Rc::new("2024-07-32".to_string())), // Invalid day
|
||||
OwnedValue::Text(Rc::new("2024-13-01".to_string())), // Invalid month
|
||||
OwnedValue::Text(Rc::new("invalid_date".to_string())), // Completely invalid string
|
||||
OwnedValue::Text(Rc::new("2024-07-21 25:00".to_string())), // Invalid hour
|
||||
OwnedValue::Text(Rc::new("2024-07-21 24:00:00".to_string())), // Invalid hour
|
||||
OwnedValue::Text(Rc::new("2024-07-21 23:60:00".to_string())), // Invalid minute
|
||||
OwnedValue::Text(Rc::new("2024-07-21 22:58:60".to_string())), // Invalid second
|
||||
OwnedValue::Text(Rc::new("2024-07-32".to_string())), // Invalid day
|
||||
OwnedValue::Text(Rc::new("2024-13-01".to_string())), // Invalid month
|
||||
OwnedValue::Text(Rc::new("invalid_date".to_string())), // Completely invalid string
|
||||
OwnedValue::Text(Rc::new("".to_string())), // Empty string
|
||||
OwnedValue::Integer(i64::MAX), // Large Julian day
|
||||
OwnedValue::Integer(-1), // Negative Julian day
|
||||
@@ -349,17 +473,15 @@ mod tests {
|
||||
OwnedValue::Float(f64::INFINITY), // Infinity
|
||||
OwnedValue::Null, // Null value
|
||||
OwnedValue::Blob(vec![1, 2, 3].into()), // Blob (unsupported type)
|
||||
|
||||
// Invalid timezone tests
|
||||
OwnedValue::Text(Rc::new("2024-07-21T12:00:00+24:00".to_string())), // Invalid timezone offset (too large)
|
||||
OwnedValue::Text(Rc::new("2024-07-21T12:00:00-24:00".to_string())), // Invalid timezone offset (too small)
|
||||
OwnedValue::Text(Rc::new("2024-07-21T12:00:00+00:60".to_string())), // Invalid timezone minutes
|
||||
OwnedValue::Text(Rc::new("2024-07-21T12:00:00+24:00".to_string())), // Invalid timezone offset (too large)
|
||||
OwnedValue::Text(Rc::new("2024-07-21T12:00:00-24:00".to_string())), // Invalid timezone offset (too small)
|
||||
OwnedValue::Text(Rc::new("2024-07-21T12:00:00+00:60".to_string())), // Invalid timezone minutes
|
||||
OwnedValue::Text(Rc::new("2024-07-21T12:00:00+00:00:00".to_string())), // Invalid timezone format (extra seconds)
|
||||
OwnedValue::Text(Rc::new("2024-07-21T12:00:00+".to_string())), // Incomplete timezone
|
||||
OwnedValue::Text(Rc::new("2024-07-21T12:00:00+Z".to_string())), // Invalid timezone format
|
||||
OwnedValue::Text(Rc::new("2024-07-21T12:00:00+".to_string())), // Incomplete timezone
|
||||
OwnedValue::Text(Rc::new("2024-07-21T12:00:00+Z".to_string())), // Invalid timezone format
|
||||
OwnedValue::Text(Rc::new("2024-07-21T12:00:00+00:00Z".to_string())), // Mixing offset and Z
|
||||
OwnedValue::Text(Rc::new("2024-07-21T12:00:00UTC".to_string())), // Named timezone (not supported)
|
||||
|
||||
OwnedValue::Text(Rc::new("2024-07-21T12:00:00UTC".to_string())), // Named timezone (not supported)
|
||||
];
|
||||
|
||||
for case in invalid_cases.iter() {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum AggFunc {
|
||||
Avg,
|
||||
@@ -67,14 +66,13 @@ pub enum Func {
|
||||
SingleRow(SingleRowFunc),
|
||||
}
|
||||
|
||||
impl Func{
|
||||
|
||||
pub fn resolve_function(name: &str, arg_count:usize) -> Result<Func, ()>{
|
||||
impl Func {
|
||||
pub fn resolve_function(name: &str, arg_count: usize) -> Result<Func, ()> {
|
||||
match name {
|
||||
"avg" => Ok(Func::Agg(AggFunc::Avg)),
|
||||
"count" => Ok(Func::Agg(AggFunc::Count)),
|
||||
"group_concat" => Ok(Func::Agg(AggFunc::GroupConcat)),
|
||||
"max" if arg_count == 0 || arg_count == 1 => Ok(Func::Agg(AggFunc::Max)),
|
||||
"max" if arg_count == 0 || arg_count == 1 => Ok(Func::Agg(AggFunc::Max)),
|
||||
"max" if arg_count > 1 => Ok(Func::SingleRow(SingleRowFunc::Max)),
|
||||
"min" if arg_count == 0 || arg_count == 1 => Ok(Func::Agg(AggFunc::Min)),
|
||||
"min" if arg_count > 1 => Ok(Func::SingleRow(SingleRowFunc::Min)),
|
||||
@@ -94,4 +92,4 @@ impl Func{
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
mod btree;
|
||||
mod buffer_pool;
|
||||
mod datetime;
|
||||
mod function;
|
||||
mod io;
|
||||
mod pager;
|
||||
@@ -11,7 +12,6 @@ mod translate;
|
||||
mod types;
|
||||
mod util;
|
||||
mod vdbe;
|
||||
mod datetime;
|
||||
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
#[global_allocator]
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::{
|
||||
schema::{Schema, Table, Type},
|
||||
translate::select::{ColumnInfo, Select, SrcTable},
|
||||
util::normalize_ident,
|
||||
vdbe::{BranchOffset, Insn, builder::ProgramBuilder},
|
||||
vdbe::{builder::ProgramBuilder, BranchOffset, Insn},
|
||||
};
|
||||
|
||||
pub fn build_select<'a>(schema: &Schema, select: &'a ast::Select) -> Result<Select<'a>> {
|
||||
@@ -226,7 +226,8 @@ pub fn translate_expr(
|
||||
filter_over: _,
|
||||
} => {
|
||||
let args_count = if let Some(args) = args { args.len() } else { 0 };
|
||||
let func_type: Option<Func> = Func::resolve_function(normalize_ident(name.0.as_str()).as_str(),args_count).ok();
|
||||
let func_type: Option<Func> =
|
||||
Func::resolve_function(normalize_ident(name.0.as_str()).as_str(), args_count).ok();
|
||||
|
||||
match func_type {
|
||||
Some(Func::Agg(_)) => {
|
||||
@@ -355,10 +356,16 @@ pub fn translate_expr(
|
||||
anyhow::bail!("Parse error: date function with > 1 arguments. Modifiers are not yet supported.");
|
||||
} else if args.len() == 1 {
|
||||
let arg_reg = program.alloc_register();
|
||||
let _ = translate_expr(program, select, &args[0], arg_reg, cursor_hint)?;
|
||||
let _ = translate_expr(
|
||||
program,
|
||||
select,
|
||||
&args[0],
|
||||
arg_reg,
|
||||
cursor_hint,
|
||||
)?;
|
||||
start_reg = arg_reg;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
program.emit_insn(Insn::Function {
|
||||
start_reg: start_reg,
|
||||
dest: target_register,
|
||||
@@ -605,10 +612,12 @@ pub fn analyze_expr<'a>(expr: &'a Expr, column_info_out: &mut ColumnInfo<'a>) {
|
||||
filter_over: _,
|
||||
} => {
|
||||
let args_count = if let Some(args) = args { args.len() } else { 0 };
|
||||
let func_type = match Func::resolve_function(normalize_ident(name.0.as_str()).as_str(),args_count) {
|
||||
Ok(func) => Some(func),
|
||||
Err(_) => None,
|
||||
};
|
||||
let func_type =
|
||||
match Func::resolve_function(normalize_ident(name.0.as_str()).as_str(), args_count)
|
||||
{
|
||||
Ok(func) => Some(func),
|
||||
Err(_) => None,
|
||||
};
|
||||
if func_type.is_none() {
|
||||
let args = args.as_ref().unwrap();
|
||||
if !args.is_empty() {
|
||||
|
||||
@@ -15,7 +15,7 @@ use crate::translate::where_clause::{
|
||||
};
|
||||
use crate::types::{OwnedRecord, OwnedValue};
|
||||
use crate::util::normalize_ident;
|
||||
use crate::vdbe::{BranchOffset, Insn, Program, builder::ProgramBuilder};
|
||||
use crate::vdbe::{builder::ProgramBuilder, BranchOffset, Insn, Program};
|
||||
use anyhow::Result;
|
||||
use expr::{build_select, maybe_apply_affinity, translate_expr};
|
||||
use sqlite3_parser::ast::{self, Literal};
|
||||
|
||||
@@ -2,10 +2,10 @@ use anyhow::Result;
|
||||
use sqlite3_parser::ast::{self, JoinOperator};
|
||||
|
||||
use crate::{
|
||||
translate::expr::{resolve_ident_qualified, resolve_ident_table, translate_expr},
|
||||
function::SingleRowFunc,
|
||||
translate::expr::{resolve_ident_qualified, resolve_ident_table, translate_expr},
|
||||
translate::select::Select,
|
||||
vdbe::{BranchOffset, Insn, builder::ProgramBuilder},
|
||||
vdbe::{builder::ProgramBuilder, BranchOffset, Insn},
|
||||
};
|
||||
|
||||
const HARDCODED_CURSOR_LEFT_TABLE: usize = 0;
|
||||
|
||||
@@ -292,4 +292,4 @@ impl ProgramBuilder {
|
||||
cursor_ref: self.cursor_ref,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use super::{Program, InsnReference, Insn, OwnedValue};
|
||||
use super::{Insn, InsnReference, OwnedValue, Program};
|
||||
use std::rc::Rc;
|
||||
|
||||
pub fn insn_to_str(program: &Program, addr: InsnReference, insn: &Insn, indent: String) -> String {
|
||||
|
||||
@@ -1101,15 +1101,22 @@ impl Program {
|
||||
}
|
||||
SingleRowFunc::Date => {
|
||||
if *start_reg == 0 {
|
||||
let date_str = get_date_from_time_value(&OwnedValue::Text(Rc::new("now".to_string())))?;
|
||||
let date_str = get_date_from_time_value(&OwnedValue::Text(Rc::new(
|
||||
"now".to_string(),
|
||||
)))?;
|
||||
state.registers[*dest] = OwnedValue::Text(Rc::new(date_str));
|
||||
} else {
|
||||
let time_value = &state.registers[*start_reg];
|
||||
let date_str = get_date_from_time_value(time_value);
|
||||
match date_str {
|
||||
Ok(date) => state.registers[*dest] = OwnedValue::Text(Rc::new(date)),
|
||||
Ok(date) => {
|
||||
state.registers[*dest] = OwnedValue::Text(Rc::new(date))
|
||||
}
|
||||
Err(e) => {
|
||||
anyhow::bail!("Error encountered while parsing time value: {}", e)
|
||||
anyhow::bail!(
|
||||
"Error encountered while parsing time value: {}",
|
||||
e
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1141,7 +1148,10 @@ fn trace_insn(program: &Program, addr: InsnReference, insn: &Insn) {
|
||||
if !log::log_enabled!(log::Level::Trace) {
|
||||
return;
|
||||
}
|
||||
log::trace!("{}", explain::insn_to_str(program, addr, insn, String::new()));
|
||||
log::trace!(
|
||||
"{}",
|
||||
explain::insn_to_str(program, addr, insn, String::new())
|
||||
);
|
||||
}
|
||||
|
||||
fn print_insn(program: &Program, addr: InsnReference, insn: &Insn, indent: String) {
|
||||
@@ -1285,8 +1295,8 @@ fn exec_if(reg: &OwnedValue, null_reg: &OwnedValue, not: bool) -> bool {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{
|
||||
exec_abs, exec_if, exec_length, exec_like, exec_lower, exec_minmax, exec_random, exec_round, exec_trim,
|
||||
exec_upper, OwnedValue,
|
||||
exec_abs, exec_if, exec_length, exec_like, exec_lower, exec_minmax, exec_random,
|
||||
exec_round, exec_trim, exec_upper, OwnedValue,
|
||||
};
|
||||
use std::rc::Rc;
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ fn main() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
Err(_) => {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user