public string submitQuerySQL(string sql, out DataTable answerSet) { SqlQuery rawQuery = new SqlQuery(sql); QueryType qType = rawQuery.ProcessType(); answerSet = null; switch (qType) { case QueryType.INSERT: var query = new SqlInsertQuery(sql); query.ProcessAndPopulateEachField(); var iHandler = new InsertQueryHandler(query, underlineDatabase); answerSet = iHandler.HandleInsertQuery(); break; case QueryType.SELECT: var squery = new SqlSelectQuery(sql); var sHandler = new SelectQueryHandler(squery, underlineDatabase); answerSet = sHandler.HandleSelectSqlQuery(); break; case QueryType.CREATE: var cquery = new SqlCreateTableQuery(sql); var handler = new CreateTableHandler(cquery,underlineDatabase); answerSet = handler.HandleCreateTableQuery(); break; default: break; } return "end of submitSQL function"; }
public void TestInsertWithFullyDependentColumns() { string sentences = "INSERT INTO socialData(att1,att3,att2,att4) VALUES (351,Smith,PROBABLY [785 Single] 25%/ [185 Married] 75%)"; SqlInsertQuery query = new SqlInsertQuery(sentences); query.ProcessAndPopulateEachField(); Assert.IsTrue((int)query.TupleP == 100); Assert.IsTrue(query.TableName == "socialData"); Assert.IsTrue(query.Attributes.Count == 3); var multiColumn = (ProbabilisticMultiAttribute)query.Attributes[2]; Assert.IsTrue(multiColumn.MultiAttrbutes.Count == 2); Assert.IsTrue((int)multiColumn.PValues[0] == 25); Assert.IsTrue((int)multiColumn.PValues[1] == 75); var value1 = multiColumn.MultiAttrbutes[0]; Assert.IsTrue(value1.Count == 2); Assert.IsTrue(value1[0] == "785"); Assert.IsTrue(value1[1] == "Single"); var value2 = multiColumn.MultiAttrbutes[1]; Assert.IsTrue(value2.Count == 2); Assert.IsTrue(value2[0] == "185"); Assert.IsTrue(value2[1] == "Married"); }
public void TestInsertWithColumnNameSpecified() { string sentences = "INSERT INTO socialData(att1,att3,att2,att4) VALUES (351,Smith,hoho,haha)"; SqlInsertQuery query = new SqlInsertQuery(sentences); query.ProcessAndPopulateEachField(); var colNames = query.ColNames; Assert.IsNotNull(colNames); Assert.IsTrue(colNames.Count == 4); Assert.IsTrue(colNames[0] == "att1"); Assert.IsTrue(colNames[1] == "att3"); Assert.IsTrue(colNames[2] == "att2"); Assert.IsTrue(colNames[3] == "att4"); }
public void TestComplexProbabilisticSqlInsert() { string sentences = "INSERT INTO socialData VALUES (351,PROBABLY 785 25%/ 185 70% ,Smith,Single) probably 50%"; SqlInsertQuery query = new SqlInsertQuery(sentences); query.ProcessAndPopulateEachField(); Assert.IsTrue(query.TupleP == 50.0); Assert.IsTrue(query.TableName == "socialData"); Assert.IsTrue(query.Attributes.Count == 4); ProbabilisticSingleAttribute p = (ProbabilisticSingleAttribute)query.Attributes[1]; Assert.IsTrue(p.Values[0] == "785"); Assert.IsTrue(p.Probs[0] == 25.0); Assert.IsTrue(p.Values[1] == "185"); Assert.IsTrue(p.Probs[1] == 70.0); }
public void TestNormalSqlInsert() { string sentences = "INSERT INTO socialData VALUES (351,785,Smith,Single)"; SqlInsertQuery query = new SqlInsertQuery(sentences); query.ProcessAndPopulateEachField(); Assert.IsTrue(query.TupleP == 100.0); Assert.IsTrue(query.TableName == "socialData"); Assert.IsTrue(query.Attributes.Count == 4); }