Sql: More adjustments of sch introspection

git-svn-id: svn://ultimatepp.org/upp/trunk@4275 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2011-12-08 19:42:54 +00:00
parent 0408bc9c75
commit 910902fe7e
4 changed files with 14 additions and 2 deletions

View file

@ -110,6 +110,7 @@ inline void SqlSchemaClear(T *a, int n) {
void SchDbInfoTable(const char *table);
void SchDbInfoColumn(const char *column);
void SchDbInfoColumnArray(const char *name, int items);
void SchDbInfoVar(void (*fn)(), const char *name);
void SchDbInfoPrimaryKey();
void SchDbInfoReferences(const char *table);

View file

@ -189,6 +189,16 @@ SqlSelect& SqlSelect::From(SqlId table1, SqlId table2, SqlId table3) {
return *this;
}
SqlSelect& SqlSelect::From(SqlCol table1, SqlCol table2, SqlCol table3) {
String t1 = ~table1;
String t2 = ~table2;
String t3 = ~table3;
text = "select " + text + " from " + t1 + ", " + t2 + ", " + t3;
tables << ',' << t1 << ',' << t2 << ',' << t3;
on = false;
return *this;
}
SqlSelect& SqlSelect::InnerJoin0(const String& table) {
text << " inner join " << table;
tables << ',' << table;

View file

@ -509,6 +509,7 @@ public:
SqlSelect& From(SqlId table1, SqlId table2);
SqlSelect& From(SqlCol table1, SqlCol table2);
SqlSelect& From(SqlId table1, SqlId table2, SqlId table3);
SqlSelect& From(SqlCol table1, SqlCol table2, SqlCol table3);
SqlSelect& From(const SqlVal& a) { return From(SqlSet(a)); }
SqlSelect& InnerJoin(SqlId table) { return InnerJoin0(~table); }

View file

@ -140,7 +140,7 @@ void S_##x::FieldLayoutRaw(FieldOperator& fo, const String& prefix) {\
#define REFERENCES_CASCADE_(table, column) SchDbInfoReferences(#table, #column);
#define PRIMARY_KEY SchDbInfoPrimaryKey();
#define COLUMN_ARRAY(type, ctype, name, width, prec, items) SchDbInfoColumnArray(#name, items);
#define END_TABLE }
#define END_TYPE }
#include SCHEMADIALECT
@ -149,6 +149,6 @@ void S_##x::FieldLayoutRaw(FieldOperator& fo, const String& prefix) {\
#define TYPE_I(x, b) TYPE(x)
#define TYPE_II(x, b1, b2) TYPE(x)
#define TYPE_III(x, b1, b2, b3) TYPE(x)
#define END_TABLE }
#define END_TYPE }
#include SCHEMADIALECT