mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-24 06:12:52 -06:00
Sql: SqlId escaping now tests whether escaped Id is indeed valid SQL id, no escaping otherwise (workaround for use of SqlId('table.*') and similar)
git-svn-id: svn://ultimatepp.org/upp/trunk@4529 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
aac38bf81d
commit
ff686cb02e
4 changed files with 13 additions and 10 deletions
|
|
@ -43,15 +43,20 @@ void SqlCompile(const char *&s, StringBuffer *r, byte dialect)
|
|||
break;
|
||||
case SQLC_ID: {
|
||||
for(;;) {
|
||||
if(r)
|
||||
*r << quote;
|
||||
const char *b = s;
|
||||
while((byte)*s >= 32)
|
||||
bool do_quote = IsAlpha(*s) || *s == '_' || *s == '$';
|
||||
while((byte)*s >= 32) {
|
||||
if(!(IsAlNum(*s) || *s == '_' || *s == '$'))
|
||||
do_quote = false;
|
||||
s++;
|
||||
}
|
||||
int c = *s;
|
||||
if(r) {
|
||||
if(do_quote)
|
||||
*r << quote;
|
||||
r->Cat(b, s);
|
||||
*r << quote;
|
||||
if(do_quote)
|
||||
*r << quote;
|
||||
if(c == SQLC_AS) {
|
||||
if(dialect & (MSSQL | PGSQL))
|
||||
*r << " as ";
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ SqlSelect& SqlSelect::Hint(const char *hint)
|
|||
}
|
||||
|
||||
SqlSelect& SqlSelect::Get() {
|
||||
text = "select " + text + SqlCase(ORACLE, "from DUAL")("");
|
||||
text = "select " + text + SqlCase(ORACLE, " from DUAL")("");
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -249,11 +249,9 @@ SqlVal Count(const SqlSet& exp)
|
|||
return SqlFunc("count", exp);
|
||||
}
|
||||
|
||||
SqlVal SqlAll()
|
||||
SqlId SqlAll()
|
||||
{
|
||||
SqlVal val;
|
||||
val.SetHigh("*");
|
||||
return val;
|
||||
return SqlId("*");
|
||||
}
|
||||
|
||||
SqlVal SqlCountRows()
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ SqlVal Distinct(const SqlVal& exp);
|
|||
SqlSet Distinct(const SqlSet& columns);
|
||||
SqlVal All(const SqlVal& exp);
|
||||
SqlSet All(const SqlSet& columns);
|
||||
SqlVal SqlAll();
|
||||
SqlId SqlAll();
|
||||
SqlVal Count(const SqlVal& exp);
|
||||
SqlVal Count(const SqlSet& exp);
|
||||
SqlVal SqlCountRows();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue