Skip to content

Commit

Permalink
store: Change the way we determine the type for 'id' fields
Browse files Browse the repository at this point in the history
We now take `ID` to be synonymous with `String` and allow any type as a
primary key
  • Loading branch information
lutter committed Apr 16, 2020
1 parent 230afc0 commit 992b58f
Show file tree
Hide file tree
Showing 5 changed files with 171 additions and 100 deletions.
10 changes: 5 additions & 5 deletions store/postgres/examples/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ extern crate clap;
extern crate graph_store_postgres;

use clap::App;
use graphql_parser::parse_schema;
use std::fs;
use std::process::exit;

use graph::prelude::SubgraphDeploymentId;
use graph::prelude::{Schema, SubgraphDeploymentId};
use graph_store_postgres::relational::{ColumnType, Layout};

pub fn usage(msg: &str) -> ! {
Expand Down Expand Up @@ -136,11 +135,12 @@ pub fn main() {
let db_schema = args.value_of("db_schema").unwrap_or("rel");
let kind = args.value_of("generate").unwrap_or("ddl");

let schema = ensure(fs::read_to_string(schema), "Can not read schema file");
let schema = ensure(parse_schema(&schema), "Failed to parse schema");
let subgraph = SubgraphDeploymentId::new("Qmasubgraph").unwrap();
let schema = ensure(fs::read_to_string(schema), "Can not read schema file");
let schema = ensure(Schema::parse(&schema, subgraph), "Failed to parse schema");

let layout = ensure(
Layout::new(&schema, subgraph, db_schema),
Layout::new(&schema, db_schema),
"Failed to construct Mapping",
);
match kind {
Expand Down
12 changes: 4 additions & 8 deletions store/postgres/src/entities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -792,13 +792,9 @@ impl Connection {
self.conn.batch_execute(&*query)?;

match *GRAPH_STORAGE_SCHEME {
v::Relational => Layout::create_relational_schema(
&self.conn,
&schema_name,
schema.id.clone(),
&schema.document,
)
.map(|_| ()),
v::Relational => {
Layout::create_relational_schema(&self.conn, schema, schema_name).map(|_| ())
}
v::Split => create_split_schema(&self.conn, &schema_name),
}
}
Expand Down Expand Up @@ -1291,7 +1287,7 @@ impl Storage {
}
V::Relational => {
let subgraph_schema = store.input_schema(subgraph)?;
let layout = Layout::new(&subgraph_schema.document, subgraph.clone(), schema.name)?;
let layout = Layout::new(subgraph_schema.as_ref(), &schema.name)?;
Storage::Relational(layout)
}
};
Expand Down
Loading

0 comments on commit 992b58f

Please sign in to comment.