private void GetColumnData(TableMap map) { string sql = String.Format(selectColumns, map.TableName); SqlStatement stmt = broker.GetStatement(sql); stmt.StatementType = StatementType.Select; SqlResult sr = stmt.Execute(); for (int i = 0; i < sr.Rows.Count; i++) { // returns columns: Field, Type, Null, Key, Default, Extra string columnName = sr.GetString(i, "Field"); FieldMap fm = map.GetFieldMapFromColumn(columnName); if (fm == null) { fm = new FieldMap(map, columnName); map.Fields.Add(fm); } if (fm != null) { string typeinfo = sr.GetString(i, "Type"); bool isUnsigned; fm.SetDbType(ExtractType(typeinfo, out isUnsigned), isUnsigned); if (fm.DbType == (long)MySqlDbType.Enum) { fm.HandleEnumAsString = true; } fm.SetSize(ExtractSize(typeinfo)); fm.SetIsNullable(sr.GetString(i, "Null").Equals("YES")); fm.SetIsPrimaryKey(sr.GetString(i, "Key").Equals("PRI")); if (fm.IsPrimaryKey) { fm.SetIsAutoGenerated(sr.GetString(i, "Extra").Equals("auto_increment")); } } else // raise an error if we've detected a database/type mismatch { bool hasDefault = sr.GetObject(i, "Default") != null; // TODO disabled due to code restructuring // Check.Verify( isNullable || hasDefault, Error.NoPropertyForNotNullColumn, column, map.Type ); } } }