Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Web/Managers/DbManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ private DbModel GetDbModel(DatabaseType type, DbConnection conn, int connectionI
+ " AND C.TABLE_NAME = PK.TABLE_NAME "
+ " AND C.COLUMN_NAME = PK.COLUMN_NAME "
+ "WHERE C.TABLE_SCHEMA = @schema "
+ "ORDER BY C.TABLE_NAME, COLUMN_NAME;";
+ "ORDER BY C.TABLE_NAME, C.ORDINAL_POSITION;";
cmd = CreateCommand(type, conn, sql);
cmd.Parameters.Add(new MySqlParameter("@schema", databaseName));
}
Expand Down Expand Up @@ -276,7 +276,7 @@ private DbModel GetDbModel(DatabaseType type, DbConnection conn, int connectionI
result.Tables.Add(currentTable);
}

if (tableName == currentTable.Name)
if (tableName == currentTable.Name)
{
currentTable.Columns.Add(new QueryTree.Models.DbColumn
{
Expand Down Expand Up @@ -354,7 +354,7 @@ private static void SetDbForeignKeys(DbModel dbModel, DatabaseType type, DbConne
break;
case DatabaseType.SQLServer:
{
string sql = "SELECT C.TABLE_SCHEMA AS CHILD_TABLE_SCHEMA, "
string sql = "SELECT C.TABLE_SCHEMA AS CHILD_TABLE_SCHEMA, "
+ " C.TABLE_NAME AS CHILD_TABLE_NAME, "
+ " C.COLUMN_NAME AS CHILD_COLUMN_NAME, "
+ " P.TABLE_SCHEMA AS PARENT_TABLE_SCHEMA, "
Expand Down Expand Up @@ -405,11 +405,11 @@ private static void SetDbForeignKeys(DbModel dbModel, DatabaseType type, DbConne
DbTable dbTable = null;
if (column.IsPrimaryKey == false && column.Parent == null)
{
dbTable = dbModel.Tables.FirstOrDefault(t =>
t.Schema == table.Schema &&
dbTable = dbModel.Tables.FirstOrDefault(t =>
t.Schema == table.Schema &&
((t.Name.ToLower() + "_id") == column.Name.ToLower()) ||
((t.Name.ToLower() + "id") == column.Name.ToLower()));

if (dbTable != null)
{
column.Parent = dbTable.Columns[0] as Models.DbColumn;
Expand All @@ -425,7 +425,7 @@ public static List<DbTable> GetTableParents(DbTable table)
queue.Push(table);

HashSet<DbTable> parents = new HashSet<DbTable>();

while (queue.Any())
{
var curr = queue.Pop();
Expand Down