Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/padw 112 sync function #31

Merged
merged 3 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions extension/src/controller/dv_loader.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use pg_sys::Hash;
use pgrx::prelude::*;
use std::collections::HashMap;
use crate::model::dv_schema::{self, *};
use crate::model::dv_schema::*;

pub fn column_in_dv_schemas(table_oid: u32, column_ordinal_position: i16) -> bool {

pub fn get_dv_schemas() -> Vec<DVSchema> {

// get DV_SCHEMAS via Query
let get_schemas_query: &str = r#"
Expand Down Expand Up @@ -33,13 +33,29 @@ pub fn column_in_dv_schemas(table_oid: u32, column_ordinal_position: i16) -> boo
}
});

for dv_schema in dv_schemas {
dv_schemas
}

pub fn column_in_dv_schemas(table_oid: u32, column_ordinal_position: i16) -> bool {

for dv_schema in get_dv_schemas() {
if dv_schema.contains_column(table_oid, column_ordinal_position) {return true;}
}

false
}

// Load All DV Schemas

pub fn dv_load_schemas_all() -> bool {

for dv_schema in get_dv_schemas() {
dv_data_loader(&dv_schema);
log!("DV Schema (Build ID) Loaded: {}", dv_schema.id.to_string())
}
true
}

pub fn dv_load_schema_from_build_id(build_id: &String) -> Option<DVSchema> {
let get_schema_query: &str = r#"
SELECT schema
Expand Down
13 changes: 12 additions & 1 deletion extension/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ fn build_default() -> String {
message
}

// Syncing All DV Schemas
#[pg_extern(name="sync")]
fn sync_default() -> String {
let load_complete = dv_loader::dv_load_schemas_all();
if load_complete {
"All DV schema objects updated.".to_string()
} else {
"Failed Load".to_string()
}
}

#[pg_extern]
fn source_include( schema_pattern_include: &str,
table_pattern_include: default!(Option<&str>, "NULL"),
Expand Down Expand Up @@ -152,7 +163,7 @@ fn source_column() -> Result<
row["column"].value(),
{
if is_built {
Ok(Some("built".to_string()))
Ok(Some("Built".to_string()))
} else {
row["status"].value()
}
Expand Down