Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » U++ community news and announcements » Sql column Ids now escaped
Sql column Ids now escaped [message #35350] Sat, 04 February 2012 15:24 Go to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
SqlId column names are now escaped when inserted to SqlExp and when they actually do contain valid sql IDs (or valid of/as combinations). This is to support things like

Select(SqlId("FROM")).From(TABLE)

...

Note that this changes a way how SqlId::Of and SqlId::As are represented inside SqlId (some special <32 character is inserted instead of '.' for Of, for As there were special characters before, just other). Other than that, SqlId::ToString still returns unescaped id and should be backwards compatible.

MySql is by default using '`' instead of " to do escapes, this is supported.

If SqlId does not contain valid sql id, it is not escaped. This is done to support things like:

Select(SqlId("*")).From(TABLE)

which seems to be used in existing code.

In related news, I have changed SqlAll() to return SqlId instead of SqlVal, which makes possible

Select(SqlAll().Of(TABLE)).From(TABLE)

which translates to

select TABLE.* from TABLE
Re: Sql column Ids now escaped [message #35359 is a reply to message #35350] Mon, 06 February 2012 10:46 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
mirek wrote on Sat, 04 February 2012 09:24


If SqlId does not contain valid sql id, it is not escaped. This is done to support things like:

Select(SqlId("*")).From(TABLE)

which seems to be used in existing code.



Ops, not so easy, above does not cover

Select(SqlId("current_time"))

which leads to SQL error (current_time is not schema name and cannot be escaped).

So I have changed everything in trunk:

static SqlId::UseQuotes switches quotes on for "modern" code, default is off to support legacy.

Modern code should use new SqlTxt to 'inject' SQL terms

Select(SqlTxt("current_time"))

and both of it makes checking id for being real id, which is time consuming, unnecessarry, so it is not there anymore...
Previous Topic: Refactored Value coming....
Next Topic: Settings and multiple ide instances
Goto Forum:
  


Current Time: Mon Apr 29 05:20:31 CEST 2024

Total time taken to generate the page: 0.04404 seconds