mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-09-05 17:44:55 -06:00
Sql: GetSchAll
git-svn-id: svn://ultimatepp.org/upp/trunk@11883 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
478ad4d698
commit
fee4921285
3 changed files with 37 additions and 5 deletions
|
|
@ -102,6 +102,24 @@ int sChrf(int c)
|
|||
|
||||
StaticMutex sM;
|
||||
|
||||
ArrayMap<String, Array<SchColumnInfo>> GetSchAll()
|
||||
{
|
||||
ArrayMap<String, Array<SchColumnInfo>> r;
|
||||
Mutex::Lock __(sM);
|
||||
for(int i = 0; i < sSchTableInfo().GetCount(); i++)
|
||||
if(sSchTableInfo()[i].is_table) {
|
||||
Array<SchColumnInfo>& cf = r.Add(sSchTableInfo().GetKey(i));
|
||||
const SchTableInfo& h = sSchTableInfo()[i];
|
||||
for(int j = 0; j < h.column.GetCount(); j++) {
|
||||
SchColumnInfo& f = cf.Add();
|
||||
f.name = h.column[j];
|
||||
f.references = h.ref_table[j];
|
||||
f.foreign_key = Nvl(h.ref_column[j], f.name);
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
Vector<String> GetSchTables()
|
||||
{
|
||||
Mutex::Lock __(sM);
|
||||
|
|
@ -115,7 +133,7 @@ Vector<String> GetSchTables()
|
|||
Vector<String> GetSchColumns(const String& table)
|
||||
{
|
||||
Mutex::Lock __(sM);
|
||||
return Vector<String>(GetSchTableInfo(table).column, 0);
|
||||
return clone(GetSchTableInfo(table).column);
|
||||
}
|
||||
|
||||
SqlBool FindSchJoin(const String& tables)
|
||||
|
|
|
|||
|
|
@ -120,8 +120,16 @@ void SchDbInfoReferences(const char *table, const char *column);
|
|||
|
||||
SqlBool FindSchJoin(const String& tables);
|
||||
|
||||
Vector<String> GetSchTables();
|
||||
Vector<String> GetSchColumns(const String& table);
|
||||
Vector<String> GetSchTables();
|
||||
Vector<String> GetSchColumns(const String& table);
|
||||
|
||||
struct SchColumnInfo {
|
||||
String name;
|
||||
String references;
|
||||
String foreign_key;
|
||||
};
|
||||
|
||||
ArrayMap< String, Array<SchColumnInfo> > GetSchAll();
|
||||
|
||||
String ExportSch(SqlSession& session, const String& database);
|
||||
String ExportIds(SqlSession& session, const String& database);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
topic "Schema introspection";
|
||||
[2 $$0,0#00000000000000000000000000000000:Default]
|
||||
[i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class]
|
||||
[l288;2 $$2,2#27521748481378242620020725143825:desc]
|
||||
[0 $$3,0#96390100711032703541132217272105:end]
|
||||
|
|
@ -9,6 +8,7 @@ topic "Schema introspection";
|
|||
[l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param]
|
||||
[i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam]
|
||||
[b42;2 $$9,9#13035079074754324216151401829390:normal]
|
||||
[2 $$0,0#00000000000000000000000000000000:Default]
|
||||
[{_}
|
||||
[ {{10000@(113.42.0) [s0;%% [*@7;4 Schema introspection]]}}&]
|
||||
[s3; &]
|
||||
|
|
@ -27,11 +27,17 @@ column in .sch definition is used.&]
|
|||
[s4; &]
|
||||
[s5;:GetSchTables`(`): [_^Vector^ Vector]<[_^String^ String]>_[* GetSchTables]()&]
|
||||
[s2;%% Returns a list of all tables defined by .sch schema files.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:GetSchAll`(`): [_^Upp`:`:ArrayMap^ ArrayMap]<_[_^Upp`:`:String^ String],
|
||||
[_^Upp`:`:Array^ Array]<[_^Upp`:`:SchColumnInfo^ SchColumnInfo]>_>_[* GetSchAll]()&]
|
||||
[s2;%% Returns the information of all .sch defined tables. Table
|
||||
names are map keys. SchColumnInfo contains name of column, the
|
||||
table it REFERENCES (if any) and the name of foreign key.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:GetSchColumns`(const String`&`): [_^Vector^ Vector]<[_^String^ String]>_[* GetSchColum
|
||||
ns]([@(0.0.255) const]_[_^String^ String][@(0.0.255) `&]_[*@3 table])&]
|
||||
[s2;%% Returns all columns for [%-*@3 table] defined by .sch schema
|
||||
files.&]
|
||||
[s3;%% &]
|
||||
[s0;%% ]]
|
||||
Loading…
Add table
Add a link
Reference in a new issue