public async Task read_columns() { await theConnection.OpenAsync(); await theConnection.ResetSchema("tables"); var table = new Table("people"); table.AddColumn <int>("id").AsPrimaryKey(); table.AddColumn <string>("first_name"); table.AddColumn <string>("last_name"); await CreateSchemaObjectInDatabase(table); var existing = await table.FetchExisting(theConnection); existing.ShouldNotBeNull(); existing.Identifier.ShouldBe(table.Identifier); existing.Columns.Count.ShouldBe(table.Columns.Count); for (int i = 0; i < table.Columns.Count; i++) { existing.Columns[i].Name.ShouldBe(table.Columns[i].Name); var existingType = existing.Columns[i].Type; var tableType = table.Columns[i].Type; TypeMappings.ConvertSynonyms(existingType) .ShouldBe(TypeMappings.ConvertSynonyms(tableType)); } }
private void compareColumns(Table expected, Table actual, IEnumerable <TableColumn> changedColumns) { foreach (var expectedColumn in changedColumns) { var actualColumn = actual.ColumnFor(expectedColumn.Name); var actualType = TypeMappings.ConvertSynonyms(actualColumn.Type); var expectedType = TypeMappings.ConvertSynonyms(expectedColumn.Type); // check for altered column type which can be auto converted if (actualType.EqualsIgnoreCase(expectedType) || !TypeMappings.CanAutoConvertType(actualType, expectedType)) { continue; } AlteredColumnTypes.Add(expectedColumn.AlterColumnTypeSql(expected)); AlteredColumnTypeRollbacks.Add(actualColumn.AlterColumnTypeSql(actual)); } }
protected bool Equals(TableColumn other) { return(string.Equals(Name, other.Name) && string.Equals(TypeMappings.ConvertSynonyms(Type), TypeMappings.ConvertSynonyms(other.Type))); }