.Sql: Fixing Joins/SqlId/SqlCol

git-svn-id: svn://ultimatepp.org/upp/trunk@4266 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2011-12-07 08:49:45 +00:00
parent ed6bc57370
commit 044cd307c6
3 changed files with 27 additions and 3 deletions

View file

@ -58,7 +58,7 @@ SqlBool FindSchJoin(const String& tables)
INTERLOCKED {
static VectorMap<String, SqlBool> 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

View file

@ -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;

View file

@ -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)); }