private List <DataObject> ExecuteOneQuery(JObject jsonQuery) { QueryBase queryBase; string command = ((string)jsonQuery.GetProperty("cmd").Value).Trim(); if (command == "select") { queryBase = new QuerySelect(this, jsonQuery); } else if (command == "insert") { queryBase = new QueryInsert(this, jsonQuery); } else if (command == "update") { queryBase = new QueryUpdate(this, jsonQuery); } else if (command == "delete") { queryBase = new QueryDelete(this, jsonQuery); } else { throw new AegisException(RoseResult.UnknownCommand); } var ret = queryBase.Execute(); return(ret); }
public override Node VisitQueryInsert(QueryInsert insert) { insert.Location = this.VisitExpression(insert.Location); this.composers.Clear(); Composer saveContext = this.contextComposer; bool savehcr = this.hasContextReference; Composer c = this.contextComposer = this.GetComposer(insert.Location); this.hasContextReference = false; this.VisitExpressionList(insert.HintList); this.VisitExpressionList(insert.InsertList); this.contextComposer = saveContext; this.hasContextReference = savehcr; return(this.Compose(insert, c)); }
public virtual Node VisitQueryInsert(QueryInsert insert, QueryInsert changes, QueryInsert deletions, QueryInsert insertions){ this.UpdateSourceContext(insert, changes); if (insert == null) return changes; if (changes != null){ if (deletions == null || insertions == null) Debug.Assert(false); else{ } }else if (deletions != null) return null; return insert; }
public virtual Differences VisitQueryInsert(QueryInsert insert1, QueryInsert insert2){ Differences differences = new Differences(insert1, insert2); if (insert1 == null || insert2 == null){ if (insert1 != insert2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++; return differences; } QueryInsert changes = (QueryInsert)insert2.Clone(); QueryInsert deletions = (QueryInsert)insert2.Clone(); QueryInsert insertions = (QueryInsert)insert2.Clone(); // insert1.HintList; // insert1.InsertList; // insert1.IsBracket; // insert1.Location; // insert1.Position; if (differences.NumberOfDifferences == 0){ differences.Changes = null; differences.Deletions = null; differences.Insertions = null; }else{ differences.Changes = changes; differences.Deletions = deletions; differences.Insertions = insertions; } return differences; }
public virtual Node VisitQueryInsert(QueryInsert insert){ if (insert == null) return null; insert.Location = this.VisitExpression(insert.Location); insert.HintList = this.VisitExpressionList(insert.HintList); insert.InsertList = this.VisitExpressionList(insert.InsertList); return insert; }
public override Node VisitQueryInsert(QueryInsert qi) { if (qi == null) return qi; qi.Location = this.VisitExpression(qi.Location); if (qi.Location == null || qi.Location.Type == null) return null; TypeNode sourceElementType = this.typeSystem.GetStreamElementType(qi.Location, this.TypeViewer); Cardinality card = this.typeSystem.GetCardinality(qi.Location, this.TypeViewer); TypeNode addType = sourceElementType; switch (qi.Position) { case QueryInsertPosition.In: { if (card != Cardinality.OneOrMore && card != Cardinality.ZeroOrMore) { this.HandleError(qi.Location, Error.QueryNotStream); return null; } Method m = this.GetTypeView(qi.Location.Type).GetMethod(StandardIds.Insert, SystemTypes.Int32, sourceElementType); if (m == null) m = this.GetTypeView(qi.Location.Type).GetMethod(StandardIds.Insert, SystemTypes.Int32, SystemTypes.Object); if (m == null) { this.HandleError(qi.Location, Error.QueryNotAddStream, this.GetTypeName(qi.Location.Type), this.GetTypeName(sourceElementType)); return null; } addType = m.Parameters[1].Type; break; } case QueryInsertPosition.At: case QueryInsertPosition.After: case QueryInsertPosition.Before: case QueryInsertPosition.First: case QueryInsertPosition.Last: this.HandleError(qi, Error.QueryNotSupported); break; } if (qi.InsertList == null || qi.InsertList.Count == 0) { this.HandleError(qi, Error.QueryBadInsertList); return null; } for (int i = 0, n = qi.InsertList.Count; i < n; i++) { Expression x = this.VisitExpression(qi.InsertList[i]); if (x == null || x.Type == null) { return null; } if (qi.IsBracket && x.NodeType != NodeType.AssignmentExpression) { this.HandleError(qi, Error.QueryNotSupported); return null; } qi.InsertList[i] = x; } if (qi.InsertList.Count == 1) { Expression x = qi.InsertList[0]; if (x.NodeType != NodeType.AssignmentExpression) { if (!this.typeSystem.ImplicitCoercionFromTo(x.Type, addType, this.TypeViewer)) { this.typeSystem.ImplicitCoercion(x, sourceElementType, this.TypeViewer); // produce error message return null; } } } else if (!sourceElementType.IsValueType) { if (sourceElementType.GetConstructor() == null) { this.HandleError(qi, Error.QueryMissingDefaultConstructor); return null; } } qi.HintList = this.VisitExpressionList(qi.HintList); if (qi.Type == null) return null; return qi; }
public override Node VisitQueryInsert(QueryInsert insert){ if (insert == null) return null; insert.Location = this.VisitExpression(insert.Location); if (insert.Location == null || insert.Location.Type == null) return insert; TypeNode sourceElementType = this.typeSystem.GetStreamElementType(insert.Location, this.TypeViewer); insert.Context = this.contextScope = new ContextScope(this.contextScope, sourceElementType); this.VisitExpressionList(insert.InsertList); this.contextScope = this.contextScope.Previous; insert.Type = SystemTypes.Int32; insert.HintList = this.VisitExpressionList(insert.HintList); return insert; }
public virtual void VisitQueryInsert(QueryInsert insert){ if (insert == null) return; this.VisitExpression(insert.Location); this.VisitExpressionList(insert.HintList); this.VisitExpressionList(insert.InsertList); }
public override Node VisitQueryInsert(QueryInsert insert){ if (insert == null) return null; return base.VisitQueryInsert((QueryInsert)insert.Clone()); }
public virtual Node VisitQueryInsert(QueryInsert insert1, QueryInsert insert2){ if (insert1 == null) return null; if (insert2 == null){ insert1.Location = this.VisitExpression(insert1.Location, null); insert1.HintList = this.VisitExpressionList(insert1.HintList, null); insert1.InsertList = this.VisitExpressionList(insert1.InsertList, null); }else{ insert1.Location = this.VisitExpression(insert1.Location, insert2.Location); insert1.HintList = this.VisitExpressionList(insert1.HintList, insert2.HintList); insert1.InsertList = this.VisitExpressionList(insert1.InsertList, insert2.InsertList); } return insert1; }
public override Node VisitQueryInsert(QueryInsert qi) { if (qi == null || qi.Type == null || qi.Location == null || qi.Location.Type == null) return null; TypeNode sourceElementType = this.typeSystem.GetStreamElementType(qi.Location, this.TypeViewer); Block block = new Block(new StatementList(qi.InsertList.Count + 2)); Expression source = null; if (qi.InsertList.Count == 1 && qi.InsertList[0].NodeType != NodeType.AssignmentExpression) { source = this.typeSystem.ImplicitCoercion(qi.InsertList[0], sourceElementType, this.TypeViewer); } else { source = qi.Context.Target = new Local(sourceElementType); if (!source.Type.IsValueType) { Construct cons = new Construct(); cons.Constructor = new MemberBinding(null, this.GetTypeView(source.Type).GetConstructor()); block.Statements.Add(new AssignmentStatement(source, cons)); } for( int i = 0, n = qi.InsertList.Count; i < n; i++ ) { block.Statements.Add(new ExpressionStatement(qi.InsertList[i])); } } switch( qi.Position ) { case QueryInsertPosition.In: { Method m = this.GetTypeView(qi.Location.Type).GetMethod(StandardIds.Insert, SystemTypes.Int32, sourceElementType); Method mGetCount = (m != null) ? this.GetTypeView( SystemTypes.GenericICollection.GetTemplateInstance( this.currentType, new TypeNodeList(sourceElementType)) ).GetMethod(StandardIds.getCount) : null; if (m == null) { m = this.GetTypeView(qi.Location.Type).GetMethod(StandardIds.Insert, SystemTypes.Int32, SystemTypes.Object); mGetCount = SystemTypes.ICollection.GetMethod(StandardIds.Count); } if (m != null) { MethodCall mcGetCount = new MethodCall(new MemberBinding(qi.Location, mGetCount), new ExpressionList()); mcGetCount.Type = mGetCount.ReturnType; if ((mGetCount.Flags & MethodFlags.Virtual) != 0) mcGetCount.NodeType = NodeType.Callvirt; MethodCall mc = new MethodCall(new MemberBinding(qi.Location, m), new ExpressionList(mcGetCount, source)); mc.Type = m.ReturnType; if ((m.Flags & MethodFlags.Virtual) != 0) mc.NodeType = NodeType.Callvirt; block.Statements.Add(new ExpressionStatement(mc)); block.Statements.Add(new ExpressionStatement(Literal.Int32One)); } break; } case QueryInsertPosition.After: case QueryInsertPosition.At: case QueryInsertPosition.Before: case QueryInsertPosition.First: case QueryInsertPosition.Last: break; } return this.VisitBlockExpression(new BlockExpression(block, SystemTypes.Int32)); }
public override Node VisitQueryInsert(QueryInsert insert) { insert.Location = this.VisitExpression(insert.Location); this.composers.Clear(); Composer saveContext = this.contextComposer; bool savehcr = this.hasContextReference; Composer c = this.contextComposer = this.GetComposer(insert.Location); this.hasContextReference = false; this.VisitExpressionList(insert.HintList); this.VisitExpressionList(insert.InsertList); this.contextComposer = saveContext; this.hasContextReference = savehcr; return this.Compose(insert, c); }
public EventingVisitor(Action<QueryInsert> visitQueryInsert) { VisitedQueryInsert += visitQueryInsert; } public event Action<QueryInsert> VisitedQueryInsert; public override Node VisitQueryInsert(QueryInsert insert) { if (VisitedQueryInsert != null) VisitedQueryInsert(insert); return base.VisitQueryInsert(insert); }