System.Data.SQLite
Check-in [b999c9c818]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:In the LINQ assembly, when surrounding single quotes are required for a formatted DateTime value, be sure to escape contained single quotes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tkt-8d928c3e88
Files: files | file ages | folders
SHA1: b999c9c81852687b901d94c6163df8ab6ef39b23
User & Date: mistachkin 2015-01-13 03:39:10
Context
2015-01-13
04:08
Fix extra single quotes around the formatted DateTime values in the LINQ assembly. Use GetSettingValue to access the new environment variables. Closed-Leaf check-in: 45312da90e user: mistachkin tags: tkt-8d928c3e88
03:39
In the LINQ assembly, when surrounding single quotes are required for a formatted DateTime value, be sure to escape contained single quotes. check-in: b999c9c818 user: mistachkin tags: tkt-8d928c3e88
03:34
Merge updates from trunk. check-in: a15efc1fd5 user: mistachkin tags: tkt-8d928c3e88
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to System.Data.SQLite.Linq/SQL Generation/SqlGenerator.cs.

   885    885             case PrimitiveTypeKind.Byte:
   886    886               result.Append(e.Value.ToString());
   887    887               break;
   888    888   
   889    889             case PrimitiveTypeKind.DateTime:
   890    890               bool needQuotes = NeedSingleQuotes(_manifest._dateTimeFormat);
   891    891   
   892         -            if (needQuotes)
   893         -                result.Append("\'");
   894         -
   895         -            result.Append(SQLiteConvert.ToString(
          892  +            string dateString = SQLiteConvert.ToString(
   896    893                   (System.DateTime)e.Value, _manifest._dateTimeFormat,
   897         -                _manifest._dateTimeKind, _manifest._dateTimeFormatString));
          894  +                _manifest._dateTimeKind, _manifest._dateTimeFormatString);
   898    895   
   899    896               if (needQuotes)
          897  +            {
          898  +                result.Append("\'");
          899  +                result.Append(EscapeSingleQuote(dateString, false /* IsUnicode */));
   900    900                   result.Append("\'");
   901         -
          901  +            }
          902  +            else
          903  +            {
          904  +                result.Append(dateString);
          905  +            }
   902    906               break;
   903    907   
   904    908             case PrimitiveTypeKind.Decimal:
   905    909               string strDecimal = ((Decimal)e.Value).ToString(CultureInfo.InvariantCulture);
   906    910               // if the decimal value has no decimal part, cast as decimal to preserve type
   907    911               // if the number has precision > int64 max precision, it will be handled as decimal by sql server
   908    912               // and does not need cast. if precision is lest then 20, then cast using Max(literal precision, sql default precision)