1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-04 21:28:02 +02:00

tests: improved sql dumps, renamed pgsql -> postgre

This commit is contained in:
David Grudl
2015-10-13 17:37:14 +02:00
parent 6994f6d11a
commit 3f44e96353
8 changed files with 19 additions and 17 deletions

View File

@@ -19,12 +19,12 @@ driver = sqlite3
database = :memory:
system = sqlite
[pgsql]
[postgre]
driver = postgre
host = 127.0.0.1
username = postgres
password =
system = pgsql
system = postgre
[odbc]
driver = odbc
@@ -63,9 +63,9 @@ username = root
password =
system = mysql
[pgsql-pdo]
[postgre-pdo]
driver = pdo
dsn = "pgsql:host=127.0.0.1;dbname=dibi_test"
username = postgres
password =
system = pgsql
system = postgre

View File

@@ -8,7 +8,7 @@ use Tester\Assert;
require __DIR__ . '/bootstrap.php';
if ($config['system'] !== 'pgsql') {
if ($config['system'] !== 'postgre') {
Tester\Environment::skip("Not supported system '$config[system]'.");
}

View File

@@ -161,7 +161,7 @@ if ($config['system'] === 'odbc') {
Assert::same(
reformat([
'mysql' => 'SELECT * FROM `products` LIMIT 18446744073709551615 OFFSET 50',
'pgsql' => 'SELECT * FROM "products" OFFSET 50',
'postgre' => 'SELECT * FROM "products" OFFSET 50',
'SELECT * FROM [products] LIMIT -1 OFFSET 50',
]),
$conn->translate('SELECT * FROM [products] %ofs', 50)
@@ -200,7 +200,7 @@ $args = [
"a\n%_\\'\"",
];
if ($config['system'] === 'pgsql') {
if ($config['system'] === 'postgre') {
$conn->query('SET escape_string_warning = off'); // do not log warnings
$conn->query('SET standard_conforming_strings = off');
@@ -303,7 +303,7 @@ WHERE (`test`.`a` LIKE '1995-03-01'
OR `str_null`=NULL
OR `str_not_null`='hello'
LIMIT 10",
'pgsql' => 'SELECT *
'postgre' => 'SELECT *
FROM "db"."table"
WHERE ("test"."a" LIKE \'1995-03-01\'
OR "b1" IN ( 1, 2, 3 )

View File

@@ -61,7 +61,7 @@ function reformat($s)
}
if ($config['system'] === 'mysql') {
return strtr($s, '[]', '``');
} elseif ($config['system'] === 'pgsql') {
} elseif ($config['system'] === 'postgre') {
return strtr($s, '[]', '""');
} elseif ($config['system'] === 'odbc' || $config['system'] === 'sqlite') {
return $s;

View File

@@ -7,7 +7,7 @@ USE dibi_test;
DROP TABLE IF EXISTS `products`;
CREATE TABLE `products` (
`product_id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(100) DEFAULT NULL,
`title` varchar(100) NOT NULL,
PRIMARY KEY (`product_id`),
KEY `title` (`title`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -20,7 +20,7 @@ INSERT INTO `products` (`product_id`, `title`) VALUES
DROP TABLE IF EXISTS `customers`;
CREATE TABLE `customers` (
`customer_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) DEFAULT NULL,
`name` varchar(100) NOT NULL,
PRIMARY KEY (`customer_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@@ -4,7 +4,7 @@ CREATE SCHEMA public;
CREATE TABLE products (
product_id serial NOT NULL,
title varchar(100) DEFAULT NULL,
title varchar(100) NOT NULL,
PRIMARY KEY (product_id)
);
@@ -18,7 +18,7 @@ CREATE INDEX title ON products USING btree (title);
CREATE TABLE customers (
customer_id serial NOT NULL,
name varchar(100) DEFAULT NULL,
name varchar(100) NOT NULL,
PRIMARY KEY (customer_id)
);

View File

@@ -1,6 +1,6 @@
CREATE TABLE [products] (
[product_id] INTEGER NOT NULL PRIMARY KEY,
[title] VARCHAR(100) NULL
[title] VARCHAR(100) NOT NULL
);
CREATE INDEX "title" ON "products" ("title");
@@ -11,7 +11,7 @@ INSERT INTO "products" ("product_id", "title") VALUES (3, 'Computer');
CREATE TABLE [customers] (
[customer_id] INTEGER PRIMARY KEY NOT NULL,
[name] VARCHAR(100) NULL
[name] VARCHAR(100) NOT NULL
);
INSERT INTO "customers" ("customer_id", "name") VALUES (1, 'Dave Lister');
@@ -25,7 +25,9 @@ CREATE TABLE [orders] (
[order_id] INTEGER NOT NULL PRIMARY KEY,
[customer_id] INTEGER NOT NULL,
[product_id] INTEGER NOT NULL,
[amount] FLOAT NOT NULL
[amount] FLOAT NOT NULL,
CONSTRAINT orders_product FOREIGN KEY (product_id) REFERENCES products (product_id),
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');

View File

@@ -50,7 +50,7 @@ Assert::same('products', $column->getTable()->getName());
Assert::same('s', $column->getType());
Assert::type('string', $column->getNativeType());
Assert::same(100, $column->getSize());
Assert::true($column->isNullable());
Assert::false($column->isNullable());
Assert::false($column->isAutoIncrement());
//Assert::null($column->getDefault());