1. Changes to extension.py

2. chore: cargo fmt
This commit is contained in:
Krishna Vishal
2025-01-19 04:58:05 +05:30
parent 31856315fe
commit fa0503f0ce
4 changed files with 13 additions and 9 deletions

View File

@@ -553,4 +553,4 @@ impl Func {
_ => crate::bail_parse_error!("no such function: {}", name),
}
}
}
}

View File

@@ -335,4 +335,4 @@ pub fn prepare_select_plan(
}
_ => todo!(),
}
}
}

View File

@@ -4215,4 +4215,4 @@ mod tests {
expected_str
);
}
}
}

View File

@@ -115,8 +115,12 @@ def validate_string_uuid(result):
return len(result) == 36 and result.count("-") == 4
def returns_error(result):
return "error: no such function: " in result
def returns_null(result):
return result == "" or result == b"\n" or result == b""
return result == "" or result == "\n"
def assert_now_unixtime(result):
@@ -135,10 +139,10 @@ def test_uuid(pipe):
run_test(
pipe,
"SELECT uuid4();",
returns_null,
returns_error,
"uuid functions return null when ext not loaded",
)
run_test(pipe, "SELECT uuid4_str();", returns_null)
run_test(pipe, "SELECT uuid4_str();", returns_error)
run_test(
pipe,
f".load {extension_path}",
@@ -178,7 +182,7 @@ def test_regexp(pipe):
extension_path = "./target/debug/liblimbo_regexp.so"
# before extension loads, assert no function
run_test(pipe, "SELECT regexp('a.c', 'abc');", returns_null)
run_test(pipe, "SELECT regexp('a.c', 'abc');", returns_error)
run_test(pipe, f".load {extension_path}", returns_null)
print(f"Extension {extension_path} loaded successfully.")
run_test(pipe, "SELECT regexp('a.c', 'abc');", validate_true)
@@ -225,7 +229,7 @@ def test_aggregates(pipe):
run_test(
pipe,
"SELECT median(1);",
returns_null,
returns_error,
"median agg function returns null when ext not loaded",
)
run_test(
@@ -282,4 +286,4 @@ def main():
if __name__ == "__main__":
main()
main()