チェンジセット 1643 (default)


以下の違いを無視:
日時:
2024/04/19 17:28:43 (6ヵ月前)
更新者:
hizuya@…
ログメッセージ:
  • IDENTITY しかないテーブルに INSERT 出来ない問題への対応。
場所:
framework/trunk
ファイル:
10個の追加
9個の更新

凡例:

未変更
追加
削除
  • framework/trunk/CoreLibrary/Resources/Data/DbDataOperator.st

    r1590 r1643  
    1515                ${Insert_FieldValues} 
    1616        ) 
     17        ${Insert_SeqVal} 
     18 
     19InsertDefault= 
     20        INSERT INTO 
     21                ${Insert_TableName} 
     22        DEFAULT VALUES 
    1723        ${Insert_SeqVal} 
    1824 
     
    4652        ) 
    4753 
     54ImportDefault= 
     55        INSERT INTO 
     56                ${Import_TableName} 
     57        DEFAULT VALUES 
     58 
    4859Clear= 
    4960        DELETE FROM 
  • framework/trunk/CoreLibrary/Sources/Data/Common/CommonDbUtility.cs

    r1568 r1643  
    114114 
    115115        /// <summary> 
     116        /// デフォルト値のみの INSERT を実行できるかどうかを返します。 
     117        /// </summary> 
     118        /// <value> 
     119        /// 実行できる場合は <see langword="true"/>。 
     120        /// それ以外の場合は <see langword="false"/>c&gt;。 
     121        /// </value> 
     122        public virtual bool SupportsInsertDefaultValues 
     123        { 
     124            get 
     125            { 
     126                return false; 
     127            } 
     128        } 
     129 
     130        /// <summary> 
    116131        /// LIKE 比較に指定する値として、特殊記号をエスケープした値を返します。 
    117132        /// </summary> 
  • framework/trunk/CoreLibrary/Sources/Data/DbDataOperator.cs

    r1590 r1643  
    768768            } 
    769769 
    770             if (fieldNames.Length == 0) 
     770            if (fieldNames.Length == 0 && !utility.SupportsInsertDefaultValues) 
    771771            { 
    772772                throw new ArgumentException(Resources.Argument_DbTableManager_TargetFieldNotFound, "bean"); 
     
    788788 
    789789            using (ICommonDbCommand command 
    790                 = transaction.CreateCommand(Template, "Insert", option)) 
     790                = transaction.CreateCommand( 
     791                Template, 
     792                fieldNames.Length == 0 && utility.SupportsInsertDefaultValues 
     793                    ? "InsertDefault" 
     794                    : "Insert", 
     795                option)) 
    791796            { 
    792797                foreach (KeyValuePair<string, object> param in parameterValues) 
     
    26722677                    = transaction.CreateCommand( 
    26732678                        Template, 
    2674                         "Import", 
     2679                        fieldNamesBuilder.Length == 0 && utility.SupportsInsertDefaultValues 
     2680                            ? "ImportDefault" 
     2681                            : "Import", 
    26752682                        new SqlStatementOption 
    26762683                        { 
  • framework/trunk/CoreLibrary/Sources/Data/ICommonDbUtility.cs

    r1568 r1643  
    5858        bool SupportsMultiStatement { get; } 
    5959 
     60        /// <summary> 
     61        /// デフォルト値のみの INSERT を実行できるかどうかを返します。 
     62        /// </summary> 
     63        /// <value> 
     64        /// 実行できる場合は <see langword="true"/>。 
     65        /// それ以外の場合は <see langword="false"/>c&gt;。 
     66        /// </value> 
     67        bool SupportsInsertDefaultValues { get; } 
     68 
    6069 
    6170        /// <summary> 
  • framework/trunk/CoreLibrary/Sources/Data/Sql/SqlUtility.cs

    r1568 r1643  
    9090 
    9191        /// <summary> 
     92        /// デフォルト値のみの INSERT を実行できるかどうかを返します。 
     93        /// </summary> 
     94        /// <value> 
     95        /// 実行できる場合は <see langword="true"/>。 
     96        /// それ以外の場合は <see langword="false"/>c&gt;。 
     97        /// </value> 
     98        public override bool SupportsInsertDefaultValues 
     99        { 
     100            get 
     101            { 
     102                return true; 
     103            } 
     104        } 
     105 
     106        /// <summary> 
    92107        /// LIKE 比較に指定する値として、特殊記号をエスケープした値を返します。 
    93108        /// </summary> 
  • framework/trunk/CoreTest/CoreTest.csproj

    r1630 r1643  
    355355    <EmbeddedResource Include="TestResources\Data\DbDataOperatorImportTest\16-ConditionWithValue-2.txt" /> 
    356356  </ItemGroup> 
     357  <ItemGroup> 
     358    <EmbeddedResource Include="TestResources\Data\DbDataOperatorBasicTest\TestInsertEmpty.txt" /> 
     359  </ItemGroup> 
     360  <ItemGroup> 
     361    <EmbeddedResource Include="TestResources\Data\DbDataOperatorImportTest\17-AppendEmpty-0.txt" /> 
     362    <EmbeddedResource Include="TestResources\Data\DbDataOperatorImportTest\17-AppendEmpty-2.txt" /> 
     363    <EmbeddedResource Include="TestResources\Data\DbDataOperatorImportTest\18-TruncateEmpty-0.txt" /> 
     364    <EmbeddedResource Include="TestResources\Data\DbDataOperatorImportTest\18-TruncateEmpty-2.txt" /> 
     365    <EmbeddedResource Include="TestResources\Data\DbDataOperatorImportTest\19-ResetEmpty-0.txt" /> 
     366    <EmbeddedResource Include="TestResources\Data\DbDataOperatorImportTest\19-ResetEmpty-2.txt" /> 
     367  </ItemGroup> 
    357368  <Import Project="$(MSBuildThisFileDirectory)..\MSBuild.Common.targets" /> 
    358369</Project> 
  • framework/trunk/CoreTest/Sources/Data/DbDataOperatorBasicTest.cs

    r1480 r1643  
    9797                        transaction, 
    9898                        Stores.SameAs(GetType().Assembly, ResourceNamePrefix + "TestInsert.txt"), 
     99                        "CompareTest"); 
     100                }); 
     101        } 
     102 
     103        /// <summary> 
     104        /// 継承された空の <see cref="DbDataBean"/> を使用して <c>INSERT</c> を実行します。 
     105        /// </summary> 
     106        [Test] 
     107        public void TestInsertEmpty() 
     108        { 
     109            Execute( 
     110                delegate(ICommonDbTransaction transaction) 
     111                { 
     112                    DbDataOperator.Insert( 
     113                        transaction, 
     114                        new DumbBean()); 
     115 
     116                    AutoSequenceNumberBean autoSequenceNumberBean1 = new AutoSequenceNumberBean(); 
     117                    DbDataOperator.Insert( 
     118                        transaction, 
     119                        autoSequenceNumberBean1); 
     120 
     121                    Assert.That( 
     122                        transaction, 
     123                        Stores.SameAs(GetType().Assembly, ResourceNamePrefix + "TestInsertEmpty.txt"), 
    99124                        "CompareTest"); 
    100125                }); 
  • framework/trunk/CoreTest/Sources/Data/DbDataOperatorImportTest.cs

    r1590 r1643  
    8282        [TestCase(@"16-ConditionWithValue.txt", 0, 2, @"16-ConditionWithValue-0.txt")] 
    8383        [TestCase(@"16-ConditionWithValue.txt", 2, 2, @"16-ConditionWithValue-2.txt")] 
     84        [TestCase(@"17-AppendEmpty.txt", 0, 2, @"17-AppendEmpty-0.txt")] 
     85        [TestCase(@"17-AppendEmpty.txt", 2, 2, @"17-AppendEmpty-2.txt")] 
     86        [TestCase(@"18-TruncateEmpty.txt", 0, 2, @"18-TruncateEmpty-0.txt")] 
     87        [TestCase(@"18-TruncateEmpty.txt", 2, 2, @"18-TruncateEmpty-2.txt")] 
     88        [TestCase(@"19-ResetEmpty.txt", 0, 2, @"19-ResetEmpty-0.txt")] 
     89        [TestCase(@"19-ResetEmpty.txt", 2, 2, @"19-ResetEmpty-2.txt")] 
    8490        [TestCase(@"51-MissingColumnData.txt", 0, 3, @"51-MissingColumnData-0.txt")] 
    8591        [TestCase(@"51-MissingColumnData.txt", 2, 3, @"51-MissingColumnData-2.txt")] 
  • framework/trunk/CoreTest/Sources/Data/DbDataOperatorTestBase.cs

    r1480 r1643  
    7575        PRIMARY KEY CLUSTERED ([F_Id]) 
    7676); 
     77IF OBJECT_ID(N'SFF_DbDataOperator_Dumb', 'U') IS NOT NULL 
     78        DROP TABLE [SFF_DbDataOperator_Dumb]; 
     79CREATE TABLE [SFF_DbDataOperator_Dumb] 
     80( 
     81    [F_Id]     INT, 
     82    [F_Int32]  INT, 
     83    [F_String] NVARCHAR(100), 
     84    [F_Double] FLOAT 
     85); 
    7786" 
    7887                }, 
     
    93102IF OBJECT_ID(N'SFF_DbDataOperator_Seq', 'U') IS NOT NULL 
    94103        DROP TABLE [SFF_DbDataOperator_Seq]; 
     104IF OBJECT_ID(N'SFF_DbDataOperator_Dumb', 'U') IS NOT NULL 
     105        DROP TABLE [SFF_DbDataOperator_Dumb]; 
    95106" 
    96107                }, 
     
    469480            } 
    470481        } 
     482 
     483 
     484        /// <summary> 
     485        /// プライマリーキーの無いテーブルに対応したビーンです。 
     486        /// </summary> 
     487        [DbTable("SFF_DbDataOperator_Dumb")] 
     488        protected sealed class DumbBean : 
     489            DbDataBean 
     490        { 
     491            /// <summary> 
     492            /// ID フィールドの値。 
     493            /// </summary> 
     494            [DebuggerBrowsable(DebuggerBrowsableState.Never)] 
     495            private DbVValue<int> id; 
     496 
     497            /// <summary> 
     498            /// <see cref="int"/> 型フィールドの値。 
     499            /// </summary> 
     500            [DebuggerBrowsable(DebuggerBrowsableState.Never)] 
     501            private DbVValue<int> int32; 
     502 
     503            /// <summary> 
     504            /// <see cref="string"/> 型フィールドの値。 
     505            /// </summary> 
     506            [DebuggerBrowsable(DebuggerBrowsableState.Never)] 
     507            private DbRValue<string> @string; 
     508 
     509            /// <summary> 
     510            /// <see cref="double"/> 型フィールドの値。 
     511            /// </summary> 
     512            [DebuggerBrowsable(DebuggerBrowsableState.Never)] 
     513            private DbVValue<double> @double; 
     514 
     515 
     516            /// <summary> 
     517            /// インスタンスを作成します。 
     518            /// </summary> 
     519            internal DumbBean() 
     520            { 
     521                // AVOID 
     522            } 
     523 
     524 
     525            /// <summary> 
     526            /// ID フィールドの値を取得または設定します。 
     527            /// </summary> 
     528            /// <value> 
     529            /// ID フィールドの値。 
     530            /// </value> 
     531            [DbField("F_Id")] 
     532            internal DbVValue<int> Id 
     533            { 
     534                get 
     535                { 
     536                    return id; 
     537                } 
     538 
     539                set 
     540                { 
     541                    SetValue(value, ref id); 
     542                } 
     543            } 
     544 
     545            /// <summary> 
     546            /// <see cref="int"/> 型フィールドの値を取得または設定します。 
     547            /// </summary> 
     548            /// <value> 
     549            /// <see cref="int"/> 型フィールドの値。 
     550            /// </value> 
     551            [DbField("F_Int32")] 
     552            internal DbVValue<int> Int32 
     553            { 
     554                get 
     555                { 
     556                    return int32; 
     557                } 
     558 
     559                set 
     560                { 
     561                    SetValue(value, ref int32); 
     562                } 
     563            } 
     564 
     565            /// <summary> 
     566            /// <see cref="string"/> 型フィールドの値を取得または設定します。 
     567            /// </summary> 
     568            /// <value> 
     569            /// <see cref="string"/> 型フィールドの値。 
     570            /// </value> 
     571            [DbField("F_String")] 
     572            internal DbRValue<string> String 
     573            { 
     574                get 
     575                { 
     576                    return @string; 
     577                } 
     578 
     579                set 
     580                { 
     581                    SetValue(value, ref @string); 
     582                } 
     583            } 
     584 
     585            /// <summary> 
     586            /// <see cref="double"/> 型フィールドの値を取得または設定します。 
     587            /// </summary> 
     588            /// <value> 
     589            /// <see cref="double"/> 型フィールドの値。 
     590            /// </value> 
     591            [DbField("F_Double")] 
     592            internal DbVValue<double> Double 
     593            { 
     594                get 
     595                { 
     596                    return @double; 
     597                } 
     598 
     599                set 
     600                { 
     601                    SetValue(value, ref @double); 
     602                } 
     603            } 
     604        } 
    471605    } 
    472606} 
詳しい使い方は TracChangeset を参照してください。