diff --git a/uppsrc/Sql/IntroSch.cpp b/uppsrc/Sql/IntroSch.cpp index 3c2f9843f..ea6f6f028 100644 --- a/uppsrc/Sql/IntroSch.cpp +++ b/uppsrc/Sql/IntroSch.cpp @@ -58,7 +58,7 @@ SqlBool FindSchJoin(const String& tables) INTERLOCKED { static VectorMap cache; if(cache.GetCount() > 20000) - cache.Clear(); + cache.Clear(); // Just to defend against unlikely dynamically created SqlSelect Join permutations int q = cache.Find(tables); if(q >= 0) return cache[q]; @@ -73,9 +73,9 @@ SqlBool FindSchJoin(const String& tables) } } } - NEVER(); - return SqlBool::False(); } + NEVER_("Schema join not found"); + return SqlBool::False(); } END_UPP_NAMESPACE \ No newline at end of file diff --git a/uppsrc/Sql/SqlStatement.cpp b/uppsrc/Sql/SqlStatement.cpp index 5a628dc6f..4a0ac2cc9 100644 --- a/uppsrc/Sql/SqlStatement.cpp +++ b/uppsrc/Sql/SqlStatement.cpp @@ -152,6 +152,15 @@ SqlSelect& SqlSelect::From(SqlId table) { return *this; } +SqlSelect& SqlSelect::From(SqlCol table) +{ + String t1 = ~table; + text = "select " + text + " from " + t1; + tables << ',' << t1; + on = false; + return *this; +} + SqlSelect& SqlSelect::From(SqlId table1, SqlId table2) { String t1 = ~table1; String t2 = ~table2; @@ -161,6 +170,15 @@ SqlSelect& SqlSelect::From(SqlId table1, SqlId table2) { return *this; } +SqlSelect& SqlSelect::From(SqlCol table1, SqlCol table2) { + String t1 = ~table1; + String t2 = ~table2; + text = "select " + text + " from " + t1 + ", " + t2; + tables << ',' << t1 << ',' << t2; + on = false; + return *this; +} + SqlSelect& SqlSelect::From(SqlId table1, SqlId table2, SqlId table3) { String t1 = ~table1; String t2 = ~table2; diff --git a/uppsrc/Sql/Sqlexp.h b/uppsrc/Sql/Sqlexp.h index 5bfe299a2..ee562c966 100644 --- a/uppsrc/Sql/Sqlexp.h +++ b/uppsrc/Sql/Sqlexp.h @@ -503,7 +503,9 @@ public: SqlSelect& Get(); SqlSelect& From(const SqlSet& set); SqlSelect& From(SqlId table); + SqlSelect& From(SqlCol table); SqlSelect& From(SqlId table1, SqlId table2); + SqlSelect& From(SqlCol table1, SqlCol table2); SqlSelect& From(SqlId table1, SqlId table2, SqlId table3); SqlSelect& From(const SqlVal& a) { return From(SqlSet(a)); } @@ -511,6 +513,10 @@ public: SqlSelect& LeftJoin(SqlId table) { return LeftJoin0(~table); } SqlSelect& RightJoin(SqlId table) { return RightJoin0(~table); } SqlSelect& FullJoin(SqlId table) { return FullJoin0(~table); } + SqlSelect& InnerJoin(SqlCol table) { return InnerJoin0(~table); } + SqlSelect& LeftJoin(SqlCol table) { return LeftJoin0(~table); } + SqlSelect& RightJoin(SqlCol table) { return RightJoin0(~table); } + SqlSelect& FullJoin(SqlCol table) { return FullJoin0(~table); } SqlSelect& InnerJoin(const SqlSet& set) { return InnerJoin0(~set(SqlSet::SET)); } SqlSelect& LeftJoin(const SqlSet& set) { return LeftJoin0(~set(SqlSet::SET)); }