From 910902fe7eb36a9e643bca4ed64b74ef40dfdd7a Mon Sep 17 00:00:00 2001 From: cxl Date: Thu, 8 Dec 2011 19:42:54 +0000 Subject: [PATCH] Sql: More adjustments of sch introspection git-svn-id: svn://ultimatepp.org/upp/trunk@4275 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Sql/SqlSchema.h | 1 + uppsrc/Sql/SqlStatement.cpp | 10 ++++++++++ uppsrc/Sql/Sqlexp.h | 1 + uppsrc/Sql/sch_source.h | 4 ++-- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/uppsrc/Sql/SqlSchema.h b/uppsrc/Sql/SqlSchema.h index eda79b928..1dcb1c77e 100644 --- a/uppsrc/Sql/SqlSchema.h +++ b/uppsrc/Sql/SqlSchema.h @@ -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); diff --git a/uppsrc/Sql/SqlStatement.cpp b/uppsrc/Sql/SqlStatement.cpp index 4a0ac2cc9..079fa3815 100644 --- a/uppsrc/Sql/SqlStatement.cpp +++ b/uppsrc/Sql/SqlStatement.cpp @@ -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; diff --git a/uppsrc/Sql/Sqlexp.h b/uppsrc/Sql/Sqlexp.h index bebb65f48..658214c57 100644 --- a/uppsrc/Sql/Sqlexp.h +++ b/uppsrc/Sql/Sqlexp.h @@ -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); } diff --git a/uppsrc/Sql/sch_source.h b/uppsrc/Sql/sch_source.h index 37506b99f..d559bca3a 100644 --- a/uppsrc/Sql/sch_source.h +++ b/uppsrc/Sql/sch_source.h @@ -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