/** * <p> This method updates the <code>Insert</code> object it receives as an * argument by replacing the virtual groups/elements with their physical * counterparts.</p> * @param obj The Insert object to be updated with physical groups/elements */ public void visit(Insert obj) { List physicalElements = new ArrayList(); // get the GroupSymbol on the insert GroupSymbol virtualGroup = obj.getGroup(); obj.setGroup(getMappedGroup(virtualGroup)); // get all virtual columns present on the Insert and replace them with // physical elements if(obj.getVariables() != null) { Iterator elementIter = obj.getVariables().iterator(); while(elementIter.hasNext()) { ElementSymbol virtualElement = (ElementSymbol) elementIter.next(); physicalElements.add(getMappedElement(virtualElement)); } obj.setVariables(physicalElements); } }
/** * <p> This method updates the <code>Insert</code> object it receives as an * argument by replacing the virtual groups/elements with their physical * counterparts.</p> * @param obj The Insert object to be updated with physical groups/elements */ public void visit(Insert obj) { List physicalElements = new ArrayList(); // get the GroupSymbol on the insert GroupSymbol virtualGroup = obj.getGroup(); obj.setGroup(getMappedGroup(virtualGroup)); // get all virtual columns present on the Insert and replace them with // physical elements if(obj.getVariables() != null) { Iterator elementIter = obj.getVariables().iterator(); while(elementIter.hasNext()) { ElementSymbol virtualElement = (ElementSymbol) elementIter.next(); physicalElements.add(getMappedElement(virtualElement)); } obj.setVariables(physicalElements); } }
/** * <p> This method updates the <code>Insert</code> object it receives as an * argument by replacing the virtual groups/elements with their physical * counterparts.</p> * @param obj The Insert object to be updated with physical groups/elements */ public void visit(Insert obj) { List physicalElements = new ArrayList(); // get the GroupSymbol on the insert GroupSymbol virtualGroup = obj.getGroup(); obj.setGroup(getMappedGroup(virtualGroup)); // get all virtual columns present on the Insert and replace them with // physical elements if(obj.getVariables() != null) { Iterator elementIter = obj.getVariables().iterator(); while(elementIter.hasNext()) { ElementSymbol virtualElement = (ElementSymbol) elementIter.next(); physicalElements.add(getMappedElement(virtualElement)); } obj.setVariables(physicalElements); } }
public void testInsert() { GroupSymbol gs1 = exampleGroupSymbol(1); Insert insert = new Insert(); insert.setGroup(gs1); Set groups = new HashSet(); groups.add(gs1); helpTestGroups(insert, true, groups); }
@Test public void testInsert1() { Insert insert = new Insert(); insert.setGroup(new GroupSymbol("m.g1")); //$NON-NLS-1$ List<ElementSymbol> vars = new ArrayList<ElementSymbol>(); vars.add(new ElementSymbol("e1")); //$NON-NLS-1$ vars.add(new ElementSymbol("e2")); //$NON-NLS-1$ insert.setVariables(vars); List<Constant> values = new ArrayList<Constant>(); values.add(new Constant(new Integer(5))); values.add(new Constant("abc")); //$NON-NLS-1$ insert.setValues(values); helpTest(insert, "INSERT INTO m.g1 (e1, e2) VALUES (5, 'abc')"); //$NON-NLS-1$ }
public void testVisitInsert1() { Insert insert = new Insert(); insert.setGroup(exampleGroup(true, 0)); List vars = new ArrayList(); vars.add(exampleElement(true, 0)); vars.add(exampleElement(true, 1)); insert.setVariables(vars); List values = new ArrayList(); values.add(new Constant("abc")); //$NON-NLS-1$ values.add(new Constant("abc")); //$NON-NLS-1$ insert.setValues(values); helpTest(insert, getSymbolMap()); }
@Test public void testMerge1() { Insert insert = new Insert(); insert.setUpsert(true); insert.setGroup(new GroupSymbol("m.g1")); //$NON-NLS-1$ List<ElementSymbol> vars = new ArrayList<ElementSymbol>(); vars.add(new ElementSymbol("e1")); //$NON-NLS-1$ vars.add(new ElementSymbol("e2")); //$NON-NLS-1$ insert.setVariables(vars); List<Constant> values = new ArrayList<Constant>(); values.add(new Constant(new Integer(5))); values.add(new Constant("abc")); //$NON-NLS-1$ insert.setValues(values); helpTest(insert, "UPSERT INTO m.g1 (e1, e2) VALUES (5, 'abc')"); //$NON-NLS-1$ }
public void testVisitInsert2() { Insert insert = new Insert(); insert.setGroup(exampleGroup(true, 0)); List values = new ArrayList(); values.add(new Constant("abc")); //$NON-NLS-1$ values.add(new Constant("abc")); //$NON-NLS-1$ insert.setValues(values); helpTest(insert, getSymbolMap()); }
/** INSERT INTO m.g (a) VALUES (?) */ @Test public void testInsertWithReference() { Insert insert = new Insert(); insert.setGroup(new GroupSymbol("m.g")); //$NON-NLS-1$ List<ElementSymbol> vars = new ArrayList<ElementSymbol>(); vars.add(new ElementSymbol("a")); //$NON-NLS-1$ insert.setVariables(vars); List<Reference> values = new ArrayList<Reference>(); values.add(new Reference(0)); insert.setValues(values); helpTest("INSERT INTO m.g (a) VALUES (?)", //$NON-NLS-1$ "INSERT INTO m.g (a) VALUES (?)", //$NON-NLS-1$ insert); }
insert.setGroup(mapping.getGroup().clone()); insert.setUpdateInfo(ProcedureContainerResolver.getUpdateInfo(insert.getGroup(), metadata, Command.TYPE_INSERT, true)); return rewriteInsert(insert);
public void testBatchedUpdateCommand() { GroupSymbol g1 = exampleGroupSymbol(1); GroupSymbol g2 = exampleGroupSymbol(2); GroupSymbol g3 = exampleGroupSymbol(3); Insert insert = new Insert(); insert.setGroup(g1); Update update = new Update(); update.setGroup(g2); Delete delete = new Delete(); delete.setGroup(g3); List updates = new ArrayList(3); updates.add(insert); updates.add(update); updates.add(delete); Set groups = new HashSet(); groups.add(g1); groups.add(g2); groups.add(g3); helpTestGroups(new BatchedUpdateCommand(updates), true, groups); } }
insert.setGroup(mapping.getGroup().clone()); insert.setUpdateInfo(ProcedureContainerResolver.getUpdateInfo(insert.getGroup(), metadata, Command.TYPE_INSERT, true)); return rewriteInsert(insert);
@Test public void testInsertWithOption() { Insert insert = new Insert(); insert.setGroup(new GroupSymbol("m.g")); //$NON-NLS-1$ List<ElementSymbol> vars = new ArrayList<ElementSymbol>(); vars.add(new ElementSymbol("a")); //$NON-NLS-1$ insert.setVariables(vars); List<Reference> values = new ArrayList<Reference>(); values.add(new Reference(0)); insert.setValues(values); Option option = new Option(); option.setNoCache(true); insert.setOption(option); TestParser.helpTest("INSERT INTO m.g (a) VALUES (?) OPTION NOCACHE", //$NON-NLS-1$ "INSERT INTO m.g (a) VALUES (?) OPTION NOCACHE", //$NON-NLS-1$ insert); }
@Test public void testInsertWithoutColumns() { Insert insert = new Insert(); insert.setGroup(new GroupSymbol("m.g")); //$NON-NLS-1$ insert.addValue(new Constant("a")); //$NON-NLS-1$ insert.addValue(new Constant("b")); //$NON-NLS-1$ helpTest("INSERT INTO m.g VALUES ('a', 'b')", //$NON-NLS-1$ "INSERT INTO m.g VALUES ('a', 'b')", //$NON-NLS-1$ insert); }
List<Constant> constantValues = new ArrayList<Constant>(); Insert insert = new Insert(); insert.setGroup(resource.getGroupSymbol()); if (keys != null) { for (UriParameter key : keys) {
insert.setGroup(new GroupSymbol(group) ); insert.setUpsert(upsert); {if (true) return insert;}
insert.setGroup(new GroupSymbol(group) ); insert.setUpsert(upsert); {if (true) return insert;}
@Test public void testInsertIntoSelect() { GroupSymbol g = new GroupSymbol("sys.groups"); //$NON-NLS-1$ From from = new From(); from.addGroup(g); Insert insert = new Insert(); GroupSymbol groupSymbol = new GroupSymbol( "tempA" ); //$NON-NLS-1$ insert.setGroup(groupSymbol); Select select = new Select(); select.addSymbol( new Constant( 1 ) ); //$NON-NLS-1$ Query query = new Query(); query.setSelect(select); insert.setQueryExpression( query ); helpTest("insert into tempA SELECT 1", //$NON-NLS-1$ "INSERT INTO tempA SELECT 1", //$NON-NLS-1$ insert); }
insert.setGroup(new GroupSymbol("#changes")); //$NON-NLS-1$ insert.setQueryExpression(query); parent.addStatement(new CommandStatement(insert));
insert.setGroup(new GroupSymbol("#changes")); //$NON-NLS-1$ insert.setQueryExpression(query); parent.addStatement(new CommandStatement(insert));