Fixed encoding issues in MySql, new ExportIds utility (in Sql) creates a file of SQLID constants for given database

git-svn-id: svn://ultimatepp.org/upp/trunk@361 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2008-08-20 10:06:42 +00:00
parent be14fe1e48
commit 2fe3327c8e
4 changed files with 69 additions and 17 deletions

View file

@ -47,7 +47,7 @@ String ExportSch(SqlSession& session, const String& database)
break;
}
r << '\t' << sPutId(type, id, c[i].name, 8);
if(width > 0 && width < 4000)
if(width > 0 && width < 40000)
r << ", " << width;
r << ")\r\n";
}
@ -61,4 +61,35 @@ String ExportSch(const String& database)
return ExportSch(SQL.GetSession(), database);
}
static void sId(String& r, const String& id, Index<String>& done)
{
String u = ToUpper(id);
if(done.Find(u) >= 0)
return;
done.Add(u);
if(u == id)
r << "SQLID(" << id << ")\r\n";
else
r << "SQL_ID(" << u << ", " << id << ")\r\n";
}
String ExportIds(SqlSession& session, const String& database)
{
String r;
Vector<String> tab = session.EnumTables(database);
Index<String> done;
for(int i = 0; i < tab.GetCount(); i++) {
sId(r, tab[i], done);
Vector<SqlColumnInfo> c = session.EnumColumns(database, tab[i]);
for(int i = 0; i < c.GetCount(); i++)
sId(r, c[i].name, done);
}
return r;
}
String ExportIds(const String& database)
{
return ExportIds(SQL.GetSession(), database);
}
END_UPP_NAMESPACE