@Test public void testFilteredReferenceTableFK() throws Exception { String ddl = "CREATE FOREIGN TABLE \"G1\"(g1e1 integer, g1e2 varchar, PRIMARY KEY(g1e1, g1e2));\n" + "CREATE FOREIGN TABLE G2( g2e1 integer, g2e2 varchar, PRIMARY KEY(g2e1, g2e2)," + "FOREIGN KEY (g2e1, g2e2) REFERENCES G1)"; String expected = "CREATE FOREIGN TABLE G1 (\n" + "\tg1e1 integer,\n" + "\tg1e2 string,\n" + "\tPRIMARY KEY(g1e1, g1e2)\n" + ");"; Schema s = TestDDLParser.helpParse(ddl, "model").getSchema(); String metadataDDL = DDLStringVisitor.getDDLString(s, null, "G1"); assertEquals(expected, metadataDDL); }
public static String getDDLString(Schema schema, EnumSet<SchemaObjectType> types, String regexPattern) { DDLStringVisitor visitor = new DDLStringVisitor(types, regexPattern); visitor.visit(schema); return visitor.toString(); }
DDLStringVisitor { public static String getDDLString(Schema schema, EnumSet<SchemaObjectType> types, String regexPattern) { DDLStringVisitor visitor = new DDLStringVisitor(types, regexPattern); visitor.visit(schema); return visitor.toString(); } }
DDLStringVisitor { public static String getDDLString(Schema schema, EnumSet<SchemaObjectType> types, String regexPattern) { DDLStringVisitor visitor = new DDLStringVisitor(types, regexPattern); visitor.visit(schema); return visitor.toString(); } DDLStringVisitor(EnumSet<SchemaObjectType> types, String regexPattern); }
DDLStringVisitor { public static String getDDLString(Schema schema, EnumSet<SchemaObjectType> types, String regexPattern) { DDLStringVisitor visitor = new DDLStringVisitor(types, regexPattern); visitor.visit(schema); return visitor.toString(); } DDLStringVisitor(EnumSet<SchemaObjectType> types, String regexPattern); static String getDDLString(Schema schema, EnumSet<SchemaObjectType> types, String regexPattern); static String getDDLString(Database database); void visit(Database database); String addTableBody(Table table); @Override String toString(); static String getDomainDDLString(Database database); }
DDLStringVisitor { public static String getDDLString(Schema schema, EnumSet<SchemaObjectType> types, String regexPattern) { DDLStringVisitor visitor = new DDLStringVisitor(types, regexPattern); visitor.visit(schema); return visitor.toString(); } DDLStringVisitor(EnumSet<SchemaObjectType> types, String regexPattern); static String getDDLString(Schema schema, EnumSet<SchemaObjectType> types, String regexPattern); static String getDDLString(Database database); void visit(Database database); String addTableBody(Table table); @Override String toString(); static String getDomainDDLString(Database database); static final String GENERATED; }