public void GetColumnsFromArguments_ShouldReturnValidColumns() { var query = "CREATE TABLE users ( email text, phoneNumber int "; var arguments = CreateUtils.GetArgumentsFromQuery(query); var actual = CreateUtils.GetColumnsFromArguments(arguments); var expected = new string[][] { new string[] { "email", "text" }, new string[] { "phoneNumber", "int" } }; Assert.Equal(expected, actual); }
public override bool Check(string query) { var arguments = CreateUtils.GetArgumentsFromQuery(query); var columns = CreateUtils.GetColumnsFromArguments(arguments); foreach (var column in columns) { if (!GeneralUtils.GetSupportedTypes().Contains(column[1].ToLower())) { throw new UnsupportedTypeException(column[1]); } } return(this.CheckNext(query)); }
private void CreateTable(string query) { var arguments = CreateUtils.GetArgumentsFromQuery(query.Remove(query.Length - 2)); var tableName = CreateUtils.GetTableNameFromQuery(query); var columns = CreateUtils.GetColumnsFromArguments(arguments); var table = new Table(tableName); foreach (var element in columns) { var column = new Column(new Properties(element[0], element[1])); table.AddColumn(column); } this._database.AddTable(table); }
public override bool Check(string query) { var arguments = CreateUtils.GetArgumentsFromQuery(query); var columns = CreateUtils.GetColumnsFromArguments(arguments); if (!columns.All(x => x.Length == 2)) { throw new MalformedColumnsException(); } foreach (var column in columns) { if (!GeneralUtils.ContainsOnlyAlphaNumericCharacters(column[0])) { throw new ForbiddenCharactersException(column[0]); } if (column[0].ToLower() == "id") { throw new ForbiddenColumnNameException(column[0]); } } return(this.CheckNext(query)); }