mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
Change unit test to Unlink and add test to unlinkAll
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
IF OBJECT_ID('[dbo].[order_item]', 'U') IS NOT NULL DROP TABLE [dbo].[order_item];
|
||||
IF OBJECT_ID('[dbo].[order_item_with_null_fk]', 'U') IS NOT NULL DROP TABLE [dbo].[order_item_with_null_fk];
|
||||
IF OBJECT_ID('[dbo].[item]', 'U') IS NOT NULL DROP TABLE [dbo].[item];
|
||||
IF OBJECT_ID('[dbo].[order]', 'U') IS NOT NULL DROP TABLE [dbo].[order];
|
||||
IF OBJECT_ID('[dbo].[order_with_null_fk]', 'U') IS NOT NULL DROP TABLE [dbo].[order_with_null_fk];
|
||||
IF OBJECT_ID('[dbo].[category]', 'U') IS NOT NULL DROP TABLE [dbo].[category];
|
||||
IF OBJECT_ID('[dbo].[customer]', 'U') IS NOT NULL DROP TABLE [dbo].[customer];
|
||||
IF OBJECT_ID('[dbo].[profile]', 'U') IS NOT NULL DROP TABLE [dbo].[profile];
|
||||
@ -54,6 +56,13 @@ CREATE TABLE [dbo].[order] (
|
||||
) ON [PRIMARY]
|
||||
);
|
||||
|
||||
CREATE TABLE [dbo].[order_with_null_fk] (
|
||||
[id] [int] IDENTITY(1,1) NOT NULL,
|
||||
[customer_id] [int] ,
|
||||
[created_at] [int] NOT NULL,
|
||||
[total] [decimal](10,0) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE [dbo].[order_item] (
|
||||
[order_id] [int] NOT NULL,
|
||||
[item_id] [int] NOT NULL,
|
||||
@ -63,6 +72,12 @@ CREATE TABLE [dbo].[order_item] (
|
||||
[order_id] ASC,
|
||||
[item_id] ASC
|
||||
) ON [PRIMARY]
|
||||
|
||||
);CREATE TABLE [dbo].[order_item_with_null_fk] (
|
||||
[order_id] [int],
|
||||
[item_id] [int],
|
||||
[quantity] [int] NOT NULL,
|
||||
[subtotal] [decimal](10,0) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE [dbo].[null_values] (
|
||||
@ -109,9 +124,20 @@ INSERT INTO [dbo].[order] ([customer_id], [created_at], [total]) VALUES (1, 1325
|
||||
INSERT INTO [dbo].[order] ([customer_id], [created_at], [total]) VALUES (2, 1325334482, 33.0);
|
||||
INSERT INTO [dbo].[order] ([customer_id], [created_at], [total]) VALUES (2, 1325502201, 40.0);
|
||||
|
||||
INSERT INTO [dbo].[order_with_null_fk] ([customer_id], [created_at], [total]) VALUES (1, 1325282384, 110.0);
|
||||
INSERT INTO [dbo].[order_with_null_fk] ([customer_id], [created_at], [total]) VALUES (2, 1325334482, 33.0);
|
||||
INSERT INTO [dbo].[order_with_null_fk] ([customer_id], [created_at], [total]) VALUES (2, 1325502201, 40.0);
|
||||
|
||||
INSERT INTO [dbo].[order_item] ([order_id], [item_id], [quantity], [subtotal]) VALUES (1, 1, 1, 30.0);
|
||||
INSERT INTO [dbo].[order_item] ([order_id], [item_id], [quantity], [subtotal]) VALUES (1, 2, 2, 40.0);
|
||||
INSERT INTO [dbo].[order_item] ([order_id], [item_id], [quantity], [subtotal]) VALUES (2, 4, 1, 10.0);
|
||||
INSERT INTO [dbo].[order_item] ([order_id], [item_id], [quantity], [subtotal]) VALUES (2, 5, 1, 15.0);
|
||||
INSERT INTO [dbo].[order_item] ([order_id], [item_id], [quantity], [subtotal]) VALUES (2, 3, 1, 8.0);
|
||||
INSERT INTO [dbo].[order_item] ([order_id], [item_id], [quantity], [subtotal]) VALUES (3, 2, 1, 40.0);
|
||||
|
||||
INSERT INTO [dbo].[order_item_with_null_fk] ([order_id], [item_id], [quantity], [subtotal]) VALUES (1, 1, 1, 30.0);
|
||||
INSERT INTO [dbo].[order_item_with_null_fk] ([order_id], [item_id], [quantity], [subtotal]) VALUES (1, 2, 2, 40.0);
|
||||
INSERT INTO [dbo].[order_item_with_null_fk] ([order_id], [item_id], [quantity], [subtotal]) VALUES (2, 4, 1, 10.0);
|
||||
INSERT INTO [dbo].[order_item_with_null_fk] ([order_id], [item_id], [quantity], [subtotal]) VALUES (2, 5, 1, 15.0);
|
||||
INSERT INTO [dbo].[order_item_with_null_fk] ([order_id], [item_id], [quantity], [subtotal]) VALUES (2, 3, 1, 8.0);
|
||||
INSERT INTO [dbo].[order_item_with_null_fk] ([order_id], [item_id], [quantity], [subtotal]) VALUES (3, 2, 1, 40.0);
|
||||
|
Reference in New Issue
Block a user