mirror of
https://github.com/ModernRelay/omnigraph.git
synced 2026-06-15 01:55:13 +02:00
Materialize external blob URIs during branch merge
Co-Authored-By: Ragnor Comerford <ragnor.comerford@gmail.com>
This commit is contained in:
parent
da89e18e62
commit
fca2b74dee
2 changed files with 56 additions and 13 deletions
|
|
@ -379,19 +379,13 @@ impl TableStore {
|
||||||
column_name
|
column_name
|
||||||
))
|
))
|
||||||
})?;
|
})?;
|
||||||
if let Some(uri) = blob.uri() {
|
builder
|
||||||
builder
|
.push_bytes(
|
||||||
.push_uri(uri)
|
blob.read()
|
||||||
.map_err(|e| OmniError::Lance(e.to_string()))?;
|
.await
|
||||||
} else {
|
.map_err(|e| OmniError::Lance(e.to_string()))?,
|
||||||
builder
|
)
|
||||||
.push_bytes(
|
.map_err(|e| OmniError::Lance(e.to_string()))?;
|
||||||
blob.read()
|
|
||||||
.await
|
|
||||||
.map_err(|e| OmniError::Lance(e.to_string()))?,
|
|
||||||
)
|
|
||||||
.map_err(|e| OmniError::Lance(e.to_string()))?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if files.next().is_some() {
|
if files.next().is_some() {
|
||||||
|
|
|
||||||
|
|
@ -388,6 +388,55 @@ async fn branch_merge_with_blob_columns_preserves_blob_data() {
|
||||||
assert_eq!(&main_doc_bytes[..], b"Main");
|
assert_eq!(&main_doc_bytes[..], b"Main");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn branch_merge_with_external_blob_uri_materializes_payload() {
|
||||||
|
let dir = tempfile::tempdir().unwrap();
|
||||||
|
let uri = dir.path().to_str().unwrap();
|
||||||
|
let external_dir = tempfile::tempdir().unwrap();
|
||||||
|
let external_path = external_dir.path().join("external.txt");
|
||||||
|
fs::write(&external_path, b"External").unwrap();
|
||||||
|
let external_uri = format!("file://{}", external_path.display());
|
||||||
|
|
||||||
|
let mut main = Omnigraph::init(uri, BLOB_SCHEMA).await.unwrap();
|
||||||
|
load_jsonl(&mut main, "", LoadMode::Overwrite)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
main.branch_create("feature").await.unwrap();
|
||||||
|
|
||||||
|
let mut feature = Omnigraph::open(uri).await.unwrap();
|
||||||
|
load_jsonl(
|
||||||
|
&mut main,
|
||||||
|
"{\"type\":\"Document\",\"data\":{\"title\":\"main-doc\",\"content\":\"base64:TWFpbg==\",\"note\":\"main\"}}",
|
||||||
|
LoadMode::Append,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let external_data = serde_json::json!({
|
||||||
|
"type": "Document",
|
||||||
|
"data": {
|
||||||
|
"title": "external",
|
||||||
|
"content": external_uri,
|
||||||
|
"note": "branch insert",
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.to_string();
|
||||||
|
feature
|
||||||
|
.load("feature", &external_data, LoadMode::Append)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let outcome = main.branch_merge("feature", "main").await.unwrap();
|
||||||
|
assert_eq!(outcome, MergeOutcome::Merged);
|
||||||
|
|
||||||
|
let external = main
|
||||||
|
.read_blob("Document", "external", "content")
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
let external_bytes = external.read().await.unwrap();
|
||||||
|
assert_eq!(&external_bytes[..], b"External");
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn branch_merge_applies_node_insert_to_main() {
|
async fn branch_merge_applies_node_insert_to_main() {
|
||||||
let dir = tempfile::tempdir().unwrap();
|
let dir = tempfile::tempdir().unwrap();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue