System.Data.SQLite
Check-in [00b02c1aa6]
Not logged in

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

Overview
Comment:Add SQLiteCommand.Execute, SQLiteCommand.ExecuteNonQuery, and SQLiteCommand.ExecuteScalar method overloads that take a CommandBehavior parameter.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 00b02c1aa60239a68cbcfcfaf0a1c645e6cc7c77
User & Date: mistachkin 2013-09-13 01:38:43
Context
2013-09-14
00:31
Make sure the database cannot be changed by a query when the CommandBehavior.SchemaOnly flag is used. Fix for [f8dbab8baf]. check-in: 0474af7d87 user: mistachkin tags: trunk
2013-09-13
01:40
Merge updates from trunk. check-in: 15ffbd9d69 user: mistachkin tags: tkt-f8dbab8baf
01:38
Add SQLiteCommand.Execute, SQLiteCommand.ExecuteNonQuery, and SQLiteCommand.ExecuteScalar method overloads that take a CommandBehavior parameter. check-in: 00b02c1aa6 user: mistachkin tags: trunk
2013-09-12
21:30
Update SQLite core library to the latest trunk code. check-in: b5ae536a3d user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Doc/Extra/version.html.

    46     46       <p><b>1.0.89.0 - September XX, 2013 <font color="red">(release scheduled)</font></b></p>
    47     47       <ul>
    48     48         <li>Updated to <a href="http://www.sqlite.org/src/info/trunk">SQLite 3.8.1</a>.</li>
    49     49         <li>Use declared column sizes for the AnsiStringFixedLength and StringFixedLength mapped database types. Fix for <a href="http://system.data.sqlite.org/index.html/info/3113734605">[3113734605]</a>.</li>
    50     50         <li>Check the result of sqlite3_column_name function against NULL.</li>
    51     51         <li>Return false for the SQLiteParameterCollection.IsSynchronized property because it is not thread-safe.</li>
    52     52         <li>Raise the static SQLiteConnection.Changed event when any SQLiteCommand, SQLiteDataReader, or CriticalHandle derived object instance is created. Fix for <a href="http://system.data.sqlite.org/index.html/info/aba4549801">[aba4549801]</a>.</li>
           53  +      <li>Add SQLiteCommand.Execute, SQLiteCommand.ExecuteNonQuery, and SQLiteCommand.ExecuteScalar method overloads that take a CommandBehavior parameter.</li>
    53     54         <li>Revise how the extra object data is passed to the static SQLiteConnection.Changed event.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    54     55         <li>Include the XML documentation files in the NuGet packages. Fix for <a href="http://system.data.sqlite.org/index.html/info/5970d5b0a6">[5970d5b0a6]</a>.</li>
    55     56       </ul>
    56     57       <p><b>1.0.88.0 - August 7, 2013</b></p>
    57     58       <ul>
    58     59         <li>Various fixes to managed virtual table integration infrastructure.</li>
    59     60         <li>Implement workaround for an incorrect PROCESSOR_ARCHITECTURE being reported. Fix for <a href="http://system.data.sqlite.org/index.html/info/9ac9862611">[9ac9862611]</a>.</li>

Changes to System.Data.SQLite/SQLiteCommand.cs.

    20     20   #if !PLATFORM_COMPACTFRAMEWORK
    21     21     [Designer("SQLite.Designer.SQLiteCommandDesigner, SQLite.Designer, Version=" + SQLite3.DesignerVersion + ", Culture=neutral, PublicKeyToken=db937bc2d44ff139"), ToolboxItem(true)]
    22     22   #endif
    23     23     public sealed class SQLiteCommand : DbCommand, ICloneable
    24     24     {
    25     25       /// <summary>
    26     26       /// The default connection string to be used when creating a temporary
    27         -    /// connection to execute a command via the static <see cref="Execute" />
    28         -    /// method.
           27  +    /// connection to execute a command via the static
           28  +    /// <see cref="Execute(string,SQLiteExecuteType,string,object[])" /> or
           29  +    /// <see cref="Execute(string,SQLiteExecuteType,CommandBehavior,string,object[])" />
           30  +    /// methods.
    29     31       /// </summary>
    30     32       private static readonly string DefaultConnectionString = "Data Source=:memory:;";
    31     33   
    32     34       /// <summary>
    33     35       /// The command text this command is based on
    34     36       /// </summary>
    35     37       private string _commandText;
................................................................................
   688    690       /// </returns>
   689    691       public static object Execute(
   690    692           string commandText,
   691    693           SQLiteExecuteType executeType,
   692    694           string connectionString,
   693    695           params object[] args
   694    696           )
          697  +    {
          698  +        return Execute(
          699  +            commandText, executeType, CommandBehavior.Default,
          700  +            connectionString, args);
          701  +    }
          702  +
          703  +    /// <summary>
          704  +    /// This method creates a new connection, executes the query using the given
          705  +    /// execution type and command behavior, closes the connection, and returns
          706  +    /// the results.  If the connection string is null, a temporary in-memory
          707  +    /// database connection will be used.
          708  +    /// </summary>
          709  +    /// <param name="commandText">
          710  +    /// The text of the command to be executed.
          711  +    /// </param>
          712  +    /// <param name="executeType">
          713  +    /// The execution type for the command.  This is used to determine which method
          714  +    /// of the command object to call, which then determines the type of results
          715  +    /// returned, if any.
          716  +    /// </param>
          717  +    /// <param name="commandBehavior">
          718  +    /// The command behavior flags for the command.
          719  +    /// </param>
          720  +    /// <param name="connectionString">
          721  +    /// The connection string to the database to be opened, used, and closed.  If
          722  +    /// this parameter is null, a temporary in-memory databse will be used.
          723  +    /// </param>
          724  +    /// <param name="args">
          725  +    /// The SQL parameter values to be used when building the command object to be
          726  +    /// executed, if any.
          727  +    /// </param>
          728  +    /// <returns>
          729  +    /// The results of the query -OR- null if no results were produced from the
          730  +    /// given execution type.
          731  +    /// </returns>
          732  +    public static object Execute(
          733  +        string commandText,
          734  +        SQLiteExecuteType executeType,
          735  +        CommandBehavior commandBehavior,
          736  +        string connectionString,
          737  +        params object[] args
          738  +        )
   695    739       {
   696    740           if (connectionString == null)
   697    741               connectionString = DefaultConnectionString;
   698    742   
   699    743           using (SQLiteConnection connection = new SQLiteConnection(connectionString))
   700    744           {
   701    745               connection.Open();
................................................................................
   722    766                               //
   723    767                               // NOTE: Do nothing.
   724    768                               //
   725    769                               break;
   726    770                           }
   727    771                       case SQLiteExecuteType.NonQuery:
   728    772                           {
   729         -                            return command.ExecuteNonQuery();
          773  +                            return command.ExecuteNonQuery(commandBehavior);
   730    774                           }
   731    775                       case SQLiteExecuteType.Scalar:
   732    776                           {
   733         -                            return command.ExecuteScalar();
          777  +                            return command.ExecuteScalar(commandBehavior);
   734    778                           }
   735    779                       case SQLiteExecuteType.Reader:
   736    780                           {
   737         -                            return command.ExecuteReader();
          781  +                            return command.ExecuteReader(commandBehavior);
   738    782                           }
   739    783                   }
   740    784               }
   741    785           }
   742    786   
   743    787           return null;
   744    788       }
   745    789   
   746    790       /// <summary>
   747    791       /// Overrides the default behavior to return a SQLiteDataReader specialization class
   748    792       /// </summary>
   749         -    /// <param name="behavior">The flags to be associated with the reader</param>
          793  +    /// <param name="behavior">The flags to be associated with the reader.</param>
   750    794       /// <returns>A SQLiteDataReader</returns>
   751    795       public new SQLiteDataReader ExecuteReader(CommandBehavior behavior)
   752    796       {
   753    797         CheckDisposed();
   754    798         SQLiteConnection.Check(_cnn);
   755    799         InitializeForReader();
   756    800   
................................................................................
   778    822       {
   779    823         _activeReader = null;
   780    824       }
   781    825   
   782    826       /// <summary>
   783    827       /// Execute the command and return the number of rows inserted/updated affected by it.
   784    828       /// </summary>
   785         -    /// <returns></returns>
          829  +    /// <returns>The number of rows inserted/updated affected by it.</returns>
   786    830       public override int ExecuteNonQuery()
          831  +    {
          832  +        CheckDisposed();
          833  +        SQLiteConnection.Check(_cnn);
          834  +        return ExecuteNonQuery(CommandBehavior.Default);
          835  +    }
          836  +
          837  +    /// <summary>
          838  +    /// Execute the command and return the number of rows inserted/updated affected by it.
          839  +    /// </summary>
          840  +    /// <param name="behavior">The flags to be associated with the reader.</param>
          841  +    /// <returns>The number of rows inserted/updated affected by it.</returns>
          842  +    public int ExecuteNonQuery(
          843  +        CommandBehavior behavior
          844  +        )
   787    845       {
   788    846         CheckDisposed();
   789    847         SQLiteConnection.Check(_cnn);
   790    848   
   791         -      using (SQLiteDataReader reader = ExecuteReader(CommandBehavior.SingleRow | CommandBehavior.SingleResult))
          849  +      using (SQLiteDataReader reader = ExecuteReader(behavior |
          850  +          CommandBehavior.SingleRow | CommandBehavior.SingleResult))
   792    851         {
   793    852           while (reader.NextResult()) ;
   794    853           return reader.RecordsAffected;
   795    854         }
   796    855       }
   797    856   
   798    857       /// <summary>
   799    858       /// Execute the command and return the first column of the first row of the resultset
   800    859       /// (if present), or null if no resultset was returned.
   801    860       /// </summary>
   802         -    /// <returns>The first column of the first row of the first resultset from the query</returns>
          861  +    /// <returns>The first column of the first row of the first resultset from the query.</returns>
   803    862       public override object ExecuteScalar()
   804    863       {
   805    864         CheckDisposed();
   806    865         SQLiteConnection.Check(_cnn);
          866  +      return ExecuteScalar(CommandBehavior.Default);
          867  +    }
          868  +
          869  +    /// <summary>
          870  +    /// Execute the command and return the first column of the first row of the resultset
          871  +    /// (if present), or null if no resultset was returned.
          872  +    /// </summary>
          873  +    /// <param name="behavior">The flags to be associated with the reader.</param>
          874  +    /// <returns>The first column of the first row of the first resultset from the query.</returns>
          875  +    public object ExecuteScalar(
          876  +        CommandBehavior behavior
          877  +        )
          878  +    {
          879  +      CheckDisposed();
          880  +      SQLiteConnection.Check(_cnn);
   807    881   
   808         -      using (SQLiteDataReader reader = ExecuteReader(CommandBehavior.SingleRow | CommandBehavior.SingleResult))
          882  +      using (SQLiteDataReader reader = ExecuteReader(behavior |
          883  +          CommandBehavior.SingleRow | CommandBehavior.SingleResult))
   809    884         {
   810    885           if (reader.Read())
   811    886             return reader[0];
   812    887         }
   813    888         return null;
   814    889       }
   815    890   

Changes to System.Data.SQLite/SQLiteConvert.cs.

  1470   1470         /// <summary>
  1471   1471         /// Do nothing.  No method will be called.
  1472   1472         /// </summary>
  1473   1473         None = 0,
  1474   1474   
  1475   1475         /// <summary>
  1476   1476         /// The command is not expected to return a result -OR- the result is not
  1477         -      /// needed.  The <see cref="SQLiteCommand.ExecuteNonQuery" /> method will
  1478         -      /// be called.
         1477  +      /// needed.  The <see cref="SQLiteCommand.ExecuteNonQuery()" /> or
         1478  +      /// <see cref="SQLiteCommand.ExecuteNonQuery(CommandBehavior)" />  method
         1479  +      /// will be called.
  1479   1480         /// </summary>
  1480   1481         NonQuery = 1,
  1481   1482   
  1482   1483         /// <summary>
  1483   1484         /// The command is expected to return a scalar result -OR- the result should
  1484         -      /// be limited to a scalar result.  The <see cref="SQLiteCommand.ExecuteScalar" />
  1485         -      /// method will be called.
         1485  +      /// be limited to a scalar result.  The <see cref="SQLiteCommand.ExecuteScalar()" />
         1486  +      /// or <see cref="SQLiteCommand.ExecuteScalar(CommandBehavior)" /> method will
         1487  +      /// be called.
  1486   1488         /// </summary>
  1487   1489         Scalar = 2,
  1488   1490   
  1489   1491         /// <summary>
  1490   1492         /// The command is expected to return <see cref="SQLiteDataReader" /> result.
  1491         -      /// The <see cref="SQLiteCommand.ExecuteReader()" /> method will be called.
         1493  +      /// The <see cref="SQLiteCommand.ExecuteReader()" /> or
         1494  +      /// <see cref="SQLiteCommand.ExecuteReader(CommandBehavior)" /> method will
         1495  +      /// be called.
  1492   1496         /// </summary>
  1493   1497         Reader = 3,
  1494   1498   
  1495   1499         /// <summary>
  1496   1500         /// Use the default command execution type.  Using this value is the same
  1497   1501         /// as using the <see cref="SQLiteExecuteType.NonQuery" /> value.
  1498   1502         /// </summary>

Changes to Tests/tkt-e06c4caff3.eagle.

    29     29         [list param1 Double [set NaN [object invoke Double NaN]]]
    30     30   } -cleanup {
    31     31     cleanupDb $fileName
    32     32   
    33     33     unset -nocomplain NaN db fileName
    34     34   } -constraints \
    35     35   {eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} \
    36         --returnCodes 1 -match regexp -result [string map [list \n \r\n]\
           36  +-returnCodes 1 -match regexp -result [string map [list \n \r\n] \
    37     37   {^System\.Data\.SQLite\.SQLiteException \(0x80004005\): constraint failed
    38     38   t1\.x may not be NULL
    39     39   .*$}]}
    40     40   
    41     41   ###############################################################################
    42     42   
    43     43   runTest {test tkt-e06c4caff3-1.2 {NaN to NULL} -setup {

Changes to readme.htm.

   191    191   </p>
   192    192   <ul>
   193    193       <li>Updated to <a href="http://www.sqlite.org/src/info/trunk">SQLite 3.8.1</a>.</li>
   194    194       <li>Use declared column sizes for the AnsiStringFixedLength and StringFixedLength mapped database types. Fix for [3113734605].</li>
   195    195       <li>Check the result of sqlite3_column_name function against NULL.</li>
   196    196       <li>Return false for the SQLiteParameterCollection.IsSynchronized property because it is not thread-safe.</li>
   197    197       <li>Raise the static SQLiteConnection.Changed event when any SQLiteCommand, SQLiteDataReader, or CriticalHandle derived object instance is created. Fix for [aba4549801].</li>
          198  +    <li>Add SQLiteCommand.Execute, SQLiteCommand.ExecuteNonQuery, and SQLiteCommand.ExecuteScalar method overloads that take a CommandBehavior parameter.</li>
   198    199       <li>Revise how the extra object data is passed to the static SQLiteConnection.Changed event.&nbsp;<b>** Potentially Incompatible Change **</b></li>
   199    200       <li>Include the XML documentation files in the NuGet packages. Fix for [5970d5b0a6].</li>
   200    201   </ul>
   201    202   <p>
   202    203       <b>1.0.88.0 - August 7, 2013</b>
   203    204   </p>
   204    205   <ul>

Changes to www/news.wiki.

     7      7   </p>
     8      8   <ul>
     9      9       <li>Updated to [http://www.sqlite.org/src/info/trunk|SQLite 3.8.1].</li>
    10     10       <li>Use declared column sizes for the AnsiStringFixedLength and StringFixedLength mapped database types. Fix for [3113734605].</li>
    11     11       <li>Check the result of sqlite3_column_name function against NULL.</li>
    12     12       <li>Return false for the SQLiteParameterCollection.IsSynchronized property because it is not thread-safe.</li>
    13     13       <li>Raise the static SQLiteConnection.Changed event when any SQLiteCommand, SQLiteDataReader, or CriticalHandle derived object instance is created. Fix for [aba4549801].</li>
           14  +    <li>Add SQLiteCommand.Execute, SQLiteCommand.ExecuteNonQuery, and SQLiteCommand.ExecuteScalar method overloads that take a CommandBehavior parameter.</li>
    14     15       <li>Revise how the extra object data is passed to the static SQLiteConnection.Changed event.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    15     16       <li>Include the XML documentation files in the NuGet packages. Fix for [5970d5b0a6].</li>
    16     17   </ul>
    17     18   <p>
    18     19       <b>1.0.88.0 - August 7, 2013</b>
    19     20   </p>
    20     21   <ul>