1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-20 12:51:40 +02:00

tests: fixes

This commit is contained in:
David Grudl
2015-11-04 14:23:14 +01:00
parent 5aab1ff023
commit 78d24a0e74
13 changed files with 72 additions and 88 deletions

View File

@@ -6,22 +6,22 @@ USE dibi_test;
DROP TABLE IF EXISTS `products`;
CREATE TABLE `products` (
`product_id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(100) NOT NULL,
PRIMARY KEY (`product_id`),
KEY `title` (`title`)
`product_id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(100) NOT NULL,
PRIMARY KEY (`product_id`),
KEY `title` (`title`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `products` (`product_id`, `title`) VALUES
(1, 'Chair'),
(3, 'Computer'),
(2, 'Table');
(1, 'Chair'),
(3, 'Computer'),
(2, 'Table');
DROP TABLE IF EXISTS `customers`;
CREATE TABLE `customers` (
`customer_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
PRIMARY KEY (`customer_id`)
`customer_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
PRIMARY KEY (`customer_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `customers` (`customer_id`, `name`) VALUES
@@ -34,15 +34,15 @@ INSERT INTO `customers` (`customer_id`, `name`) VALUES
DROP TABLE IF EXISTS `orders`;
CREATE TABLE `orders` (
`order_id` int(11) NOT NULL AUTO_INCREMENT,
`customer_id` int(11) NOT NULL,
`product_id` int(11) NOT NULL,
`amount` float NOT NULL,
PRIMARY KEY (`order_id`),
KEY `customer_id` (`customer_id`),
KEY `product_id` (`product_id`),
CONSTRAINT `orders_ibfk_4` FOREIGN KEY (`product_id`) REFERENCES `products` (`product_id`) ON UPDATE CASCADE,
CONSTRAINT `orders_ibfk_3` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`customer_id`) ON UPDATE CASCADE
`order_id` int(11) NOT NULL AUTO_INCREMENT,
`customer_id` int(11) NOT NULL,
`product_id` int(11) NOT NULL,
`amount` float NOT NULL,
PRIMARY KEY (`order_id`),
KEY `customer_id` (`customer_id`),
KEY `product_id` (`product_id`),
CONSTRAINT `orders_ibfk_4` FOREIGN KEY (`product_id`) REFERENCES `products` (`product_id`) ON UPDATE CASCADE,
CONSTRAINT `orders_ibfk_3` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`customer_id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `orders` (`order_id`, `customer_id`, `product_id`, `amount`) VALUES

View File

@@ -1,15 +1,15 @@
CREATE TABLE products (
product_id COUNTER,
title TEXT(50)
product_id COUNTER,
title TEXT(50)
);
INSERT INTO products (product_id, title) VALUES (1, 'Chair');
INSERT INTO products (product_id, title) VALUES (2, 'Table');
INSERT INTO products (product_id, title) VALUES (3, 'Computer');
INSERT INTO products (product_id, title) VALUES (1, 'Chair');
INSERT INTO products (product_id, title) VALUES (2, 'Table');
INSERT INTO products (product_id, title) VALUES (3, 'Computer');
CREATE TABLE [customers] (
[customer_id] COUNTER,
[name] TEXT(50)
[customer_id] COUNTER,
[name] TEXT(50)
);
INSERT INTO `customers` (`customer_id`, `name`) VALUES (1, 'Dave Lister');
@@ -20,10 +20,10 @@ INSERT INTO `customers` (`customer_id`, `name`) VALUES (5, 'Kryten');
INSERT INTO `customers` (`customer_id`, `name`) VALUES (6, 'Kristine Kochanski');
CREATE TABLE [orders] (
[order_id] INTEGER,
[customer_id] INTEGER,
[product_id] INTEGER,
[amount] FLOAT
[order_id] COUNTER,
[customer_id] INTEGER,
[product_id] INTEGER,
[amount] FLOAT
);
INSERT INTO `orders` (`order_id`, `customer_id`, `product_id`, `amount`) VALUES (1, 2, 1, 7);

View File

@@ -9,9 +9,9 @@ CREATE TABLE products (
);
INSERT INTO products (product_id, title) VALUES
(1, 'Chair'),
(2, 'Table'),
(3, 'Computer');
(1, 'Chair'),
(2, 'Table'),
(3, 'Computer');
SELECT setval('products_product_id_seq', 3, TRUE);
CREATE INDEX title ON products USING btree (title);

View File

@@ -5,21 +5,21 @@ CREATE TABLE [products] (
CREATE INDEX "title" ON "products" ("title");
INSERT INTO "products" ("product_id", "title") VALUES (1, 'Chair');
INSERT INTO "products" ("product_id", "title") VALUES (2, 'Table');
INSERT INTO "products" ("product_id", "title") VALUES (3, 'Computer');
INSERT INTO "products" ("product_id", "title") VALUES (1, 'Chair');
INSERT INTO "products" ("product_id", "title") VALUES (2, 'Table');
INSERT INTO "products" ("product_id", "title") VALUES (3, 'Computer');
CREATE TABLE [customers] (
[customer_id] INTEGER PRIMARY KEY NOT NULL,
[name] VARCHAR(100) NOT NULL
);
INSERT INTO "customers" ("customer_id", "name") VALUES (1, 'Dave Lister');
INSERT INTO "customers" ("customer_id", "name") VALUES (2, 'Arnold Rimmer');
INSERT INTO "customers" ("customer_id", "name") VALUES (3, 'The Cat');
INSERT INTO "customers" ("customer_id", "name") VALUES (4, 'Holly');
INSERT INTO "customers" ("customer_id", "name") VALUES (5, 'Kryten');
INSERT INTO "customers" ("customer_id", "name") VALUES (6, 'Kristine Kochanski');
INSERT INTO "customers" ("customer_id", "name") VALUES (1, 'Dave Lister');
INSERT INTO "customers" ("customer_id", "name") VALUES (2, 'Arnold Rimmer');
INSERT INTO "customers" ("customer_id", "name") VALUES (3, 'The Cat');
INSERT INTO "customers" ("customer_id", "name") VALUES (4, 'Holly');
INSERT INTO "customers" ("customer_id", "name") VALUES (5, 'Kryten');
INSERT INTO "customers" ("customer_id", "name") VALUES (6, 'Kristine Kochanski');
CREATE TABLE [orders] (
[order_id] INTEGER NOT NULL PRIMARY KEY,
@@ -30,7 +30,7 @@ CREATE TABLE [orders] (
CONSTRAINT orders_customer FOREIGN KEY (customer_id) REFERENCES customers (customer_id)
);
INSERT INTO "orders" ("order_id", "customer_id", "product_id", "amount") VALUES (1, 2, 1, '7.0');
INSERT INTO "orders" ("order_id", "customer_id", "product_id", "amount") VALUES (2, 2, 3, '2.0');
INSERT INTO "orders" ("order_id", "customer_id", "product_id", "amount") VALUES (3, 1, 2, '3.0');
INSERT INTO "orders" ("order_id", "customer_id", "product_id", "amount") VALUES (4, 6, 3, '5.0');
INSERT INTO "orders" ("order_id", "customer_id", "product_id", "amount") VALUES (1, 2, 1, '7.0');
INSERT INTO "orders" ("order_id", "customer_id", "product_id", "amount") VALUES (2, 2, 3, '2.0');
INSERT INTO "orders" ("order_id", "customer_id", "product_id", "amount") VALUES (3, 1, 2, '3.0');
INSERT INTO "orders" ("order_id", "customer_id", "product_id", "amount") VALUES (4, 6, 3, '5.0');