1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-30 17:29:53 +02:00

Compare commits

...

13 Commits
v5.1 ... v2.3.4

Author SHA1 Message Date
David Grudl
47ef875c73 Released version 2.3.4 2015-10-26 19:31:39 +01:00
David Grudl
63c644a860 DibiFluent::fetch() uses limit only when there is no LIMIT & OFFSET (fixes 20f2093 on MSSQL) 2015-10-26 19:31:08 +01:00
David Grudl
1c3ef5f5cf DibiFluent: prevents doubled processing 2015-10-26 19:26:07 +01:00
Pavel Zelezny
9100f94b8f DibiConnection: option 'driver' can contain driver instance or class name [Closes #153] 2015-10-26 19:26:06 +01:00
David Grudl
e339eff00f tests: improved sql dumps, renamed pgsql -> postgre 2015-10-26 14:32:48 +01:00
David Grudl
48adcec6dc added DibiSqlsrvDriver as alias for DibiMsSql2005Driver 2015-10-26 14:28:55 +01:00
David Grudl
389026d697 DibiTranslator: removed die() 2015-10-23 17:20:15 +02:00
David Grudl
8f0d0fb115 Released version 2.3.3 2015-10-22 02:44:33 +02:00
David Grudl
965570c067 removed unused code 2015-10-22 02:43:57 +02:00
David Grudl
4ae4f49c21 Result: fixed normalization of float when ends with "0" [Closes #189] 2015-10-13 15:13:59 +02:00
David Grudl
5b9ffe14ba Result: normalize converts FALSE 2015-10-13 15:13:59 +02:00
castamir
2d9358e4f7 DibiFluent::fetch(): fixed limit clause duplication [Closes #188][Closes #186][Closes #185] 2015-10-09 11:41:12 +02:00
David Grudl
e3748420f5 DibiFluent: removed keyword AS from SQL [Closes #172] 2015-10-09 00:17:10 +02:00
19 changed files with 299 additions and 69 deletions

View File

@@ -30,11 +30,6 @@ class DibiMySqlReflector extends DibiObject implements IDibiReflector
*/
public function getTables()
{
/*$this->query("
SELECT TABLE_NAME as name, TABLE_TYPE = 'VIEW' as view
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = DATABASE()
");*/
$res = $this->driver->query('SHOW FULL TABLES');
$tables = array();
while ($row = $res->fetch(FALSE)) {
@@ -54,12 +49,6 @@ class DibiMySqlReflector extends DibiObject implements IDibiReflector
*/
public function getColumns($table)
{
/*$table = $this->escape($table, dibi::TEXT);
$this->query("
SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = $table AND TABLE_SCHEMA = DATABASE()
");*/
$res = $this->driver->query("SHOW FULL COLUMNS FROM {$this->driver->escape($table, dibi::IDENTIFIER)}");
$columns = array();
while ($row = $res->fetch(TRUE)) {
@@ -87,13 +76,6 @@ class DibiMySqlReflector extends DibiObject implements IDibiReflector
*/
public function getIndexes($table)
{
/*$table = $this->escape($table, dibi::TEXT);
$this->query("
SELECT *
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE TABLE_NAME = $table AND TABLE_SCHEMA = DATABASE()
AND REFERENCED_COLUMN_NAME IS NULL
");*/
$res = $this->driver->query("SHOW INDEX FROM {$this->driver->escape($table, dibi::IDENTIFIER)}");
$indexes = array();
while ($row = $res->fetch(TRUE)) {

View File

@@ -51,12 +51,6 @@ class DibiSqliteReflector extends DibiObject implements IDibiReflector
*/
public function getColumns($table)
{
$meta = $this->driver->query("
SELECT sql FROM sqlite_master WHERE type = 'table' AND name = {$this->driver->escape($table, dibi::TEXT)}
UNION ALL
SELECT sql FROM sqlite_temp_master WHERE type = 'table' AND name = {$this->driver->escape($table, dibi::TEXT)}
")->fetch(TRUE);
$res = $this->driver->query("PRAGMA table_info({$this->driver->escape($table, dibi::IDENTIFIER)})");
$columns = array();
while ($row = $res->fetch(TRUE)) {

View File

@@ -0,0 +1,14 @@
<?php
/**
* This file is part of the "dibi" - smart database abstraction layer.
* Copyright (c) 2005 David Grudl (https://davidgrudl.com)
*/
require_once dirname(__FILE__) . '/DibiMsSql2005Driver.php';
class DibiSqlsrvDriver extends DibiMsSql2005Driver
{
}

View File

@@ -38,8 +38,8 @@ class dibi
FIELD_TIME = self::TIME;
/** version */
const VERSION = '2.3.2',
REVISION = 'released on 2015-04-18';
const VERSION = '2.3.4',
REVISION = 'released on 2015-10-26';
/** sorting order */
const ASC = 'ASC',
@@ -368,18 +368,6 @@ class dibi
}
/**
* Replacement for majority of dibi::methods() in future.
*/
public static function __callStatic($name, $args)
{
//if ($name = 'select', 'update', ...') {
// return self::command()->$name($args);
//}
return call_user_func_array(array(self::getConnection(), $name), $args);
}
/********************* fluent SQL builders ****************d*g**/

View File

@@ -75,19 +75,26 @@ class DibiConnection extends DibiObject
$config['driver'] = dibi::$defaultDriver;
}
$class = preg_replace(array('#\W#', '#sql#'), array('_', 'Sql'), ucfirst(strtolower($config['driver'])));
$class = "Dibi{$class}Driver";
if (!class_exists($class)) {
include_once dirname(__FILE__) . "/../drivers/$class.php";
if ($config['driver'] instanceof IDibiDriver) {
$this->driver = $config['driver'];
$config['driver'] = get_class($this->driver);
} elseif (PHP_VERSION_ID >= 50307 && is_subclass_of($config['driver'], 'IDibiDriver')) {
$this->driver = new $config['driver'];
} else {
$class = preg_replace(array('#\W#', '#sql#'), array('_', 'Sql'), ucfirst(strtolower($config['driver'])));
$class = "Dibi{$class}Driver";
if (!class_exists($class)) {
include_once dirname(__FILE__) . "/../drivers/$class.php";
if (!class_exists($class, FALSE)) {
throw new DibiException("Unable to create instance of dibi driver '$class'.");
if (!class_exists($class, FALSE)) {
throw new DibiException("Unable to create instance of dibi driver '$class'.");
}
}
$this->driver = new $class;
}
$config['name'] = $name;
$this->config = $config;
$this->driver = new $class;
$this->translator = new DibiTranslator($this);
// profiler

View File

@@ -187,6 +187,7 @@ class DibiFluent extends DibiObject implements IDataSource
foreach ($args as $arg) {
if ($arg instanceof self) {
$this->cursor[] = '%SQL';
$arg = "($arg)";
}
$this->cursor[] = $arg;
@@ -315,7 +316,7 @@ class DibiFluent extends DibiObject implements IDataSource
*/
public function fetch()
{
if ($this->command === 'SELECT') {
if ($this->command === 'SELECT' && !$this->clauses['LIMIT'] && !$this->clauses['OFFSET']) {
return $this->query($this->_export(NULL, array('%lmt', 1)))->fetch();
} else {
return $this->query($this->_export())->fetch();
@@ -329,7 +330,7 @@ class DibiFluent extends DibiObject implements IDataSource
*/
public function fetchSingle()
{
if ($this->command === 'SELECT') {
if ($this->command === 'SELECT' && !$this->clauses['LIMIT'] && !$this->clauses['OFFSET']) {
return $this->query($this->_export(NULL, array('%lmt', 1)))->fetchSingle();
} else {
return $this->query($this->_export())->fetchSingle();
@@ -401,7 +402,7 @@ class DibiFluent extends DibiObject implements IDataSource
public function count()
{
return (int) $this->query(array(
'SELECT COUNT(*) FROM (%ex', $this->_export(), ') AS [data]',
'SELECT COUNT(*) FROM (%ex', $this->_export(), ') [data]',
))->fetchSingle();
}

View File

@@ -488,13 +488,23 @@ class DibiResult extends DibiObject implements IDataSource
continue;
}
$value = $row[$key];
if ($value === FALSE || $type === dibi::TEXT) {
if ($type === dibi::TEXT) {
} elseif ($type === dibi::INTEGER) {
$row[$key] = is_float($tmp = $value * 1) ? $value : $tmp;
} elseif ($type === dibi::FLOAT) {
$row[$key] = str_replace(',', '.', ltrim((string) ($tmp = (float) $value), '0')) === ltrim(rtrim(rtrim($value, '0'), '.'), '0') ? $tmp : $value;
$value = ltrim($value, '0');
$p = strpos($value, '.');
if ($p !== FALSE) {
$value = rtrim(rtrim($value, '0'), '.');
}
if ($value === '' || $value[0] === '.') {
$value = '0' . $value;
}
$row[$key] = $value === str_replace(',', '.', (string) ($float = (float) $value))
? $float
: $value;
} elseif ($type === dibi::BOOL) {
$row[$key] = ((bool) $value) && $value !== 'f' && $value !== 'F';

View File

@@ -215,7 +215,7 @@ final class DibiTranslator extends DibiObject
$v = $this->formatValue($v, FALSE);
$vx[] = $k . ($v === 'NULL' ? 'IS ' : '= ') . $v;
} elseif ($pair[1] === 'ex') { // TODO: this will be removed
} elseif ($pair[1] === 'ex') {
$vx[] = $k . $this->formatValue($v, 'ex');
} else {
@@ -598,7 +598,7 @@ final class DibiTranslator extends DibiObject
return $matches[9] == '' ? $this->formatValue($m, FALSE) : $m . $matches[9]; // value or identifier
}
die('this should be never executed');
throw new Exception('this should be never executed');
}

View File

@@ -24,12 +24,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
@@ -68,9 +68,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

@@ -0,0 +1,98 @@
<?php
/**
* @dataProvider ../databases.ini !=mssql
*/
use Tester\Assert;
require __DIR__ . '/bootstrap.php';
$conn = new DibiConnection($config);
$conn->loadFile(__DIR__ . "/data/$config[system].sql");
// fetch & limit
$fluent = $conn->select('*')
->from('customers')
->limit(1)
->offset(3)
->orderBy('customer_id');
Assert::same(
reformat('SELECT * FROM [customers] ORDER BY [customer_id] LIMIT 1 OFFSET 3'),
(string) $fluent
);
$fluent->fetch();
Assert::same(
reformat('SELECT * FROM [customers] ORDER BY [customer_id] LIMIT 1 OFFSET 3'),
dibi::$sql
);
$fluent->fetchSingle();
Assert::same(
reformat('SELECT * FROM [customers] ORDER BY [customer_id] LIMIT 1 OFFSET 3'),
dibi::$sql
);
Assert::same(
reformat('SELECT * FROM [customers] ORDER BY [customer_id] LIMIT 1 OFFSET 3'),
(string) $fluent
);
$fluent->limit(0);
$fluent->fetch();
Assert::same(
reformat('SELECT * FROM [customers] ORDER BY [customer_id] LIMIT 0 OFFSET 3'),
dibi::$sql
);
$fluent->fetchSingle();
Assert::same(
reformat('SELECT * FROM [customers] ORDER BY [customer_id] LIMIT 0 OFFSET 3'),
dibi::$sql
);
Assert::same(
reformat('SELECT * FROM [customers] ORDER BY [customer_id] LIMIT 0 OFFSET 3'),
(string) $fluent
);
$fluent->removeClause('limit');
try {
$fluent->fetch();
} catch (DibiException $e) {
}
Assert::same(
reformat('SELECT * FROM [customers] ORDER BY [customer_id] OFFSET 3'),
dibi::$sql
);
try {
$fluent->fetchSingle();
} catch (DibiException $e) {
}
Assert::same(
reformat('SELECT * FROM [customers] ORDER BY [customer_id] OFFSET 3'),
dibi::$sql
);
Assert::same(
reformat('SELECT * FROM [customers] ORDER BY [customer_id] OFFSET 3'),
(string) $fluent
);
$fluent->removeClause('offset');
$fluent->fetch();
Assert::same(
reformat(' SELECT * FROM [customers] ORDER BY [customer_id] LIMIT 1'),
dibi::$sql
);
$fluent->fetchSingle();
Assert::same(
reformat(' SELECT * FROM [customers] ORDER BY [customer_id] LIMIT 1'),
dibi::$sql
);
Assert::same(
reformat('SELECT * FROM [customers] ORDER BY [customer_id]'),
(string) $fluent
);

View File

@@ -1,5 +1,9 @@
<?php
/**
* @dataProvider ../databases.ini
*/
use Tester\Assert;
require __DIR__ . '/bootstrap.php';

View File

@@ -0,0 +1,130 @@
<?php
use Tester\Assert;
require __DIR__ . '/bootstrap.php';
class MockResult extends DibiResult
{
function __construct()
{}
function test($row)
{
$normalize = new ReflectionMethod('DibiResult', 'normalize');
$normalize->setAccessible(TRUE);
$normalize->invokeArgs($this, array(& $row));
return $row;
}
}
test(function () {
$result = new MockResult;
$result->setType('col', dibi::BOOL);
Assert::same(array('col' => NULL), $result->test(array('col' => NULL)));
Assert::same(array('col' => TRUE), $result->test(array('col' => TRUE)));
Assert::same(array('col' => FALSE), $result->test(array('col' => FALSE)));
Assert::same(array('col' => FALSE), $result->test(array('col' => '')));
Assert::same(array('col' => FALSE), $result->test(array('col' => '0')));
Assert::same(array('col' => TRUE), $result->test(array('col' => '1')));
Assert::same(array('col' => TRUE), $result->test(array('col' => 't')));
Assert::same(array('col' => FALSE), $result->test(array('col' => 'f')));
Assert::same(array('col' => TRUE), $result->test(array('col' => 'T')));
Assert::same(array('col' => FALSE), $result->test(array('col' => 'F')));
Assert::same(array('col' => FALSE), $result->test(array('col' => 0)));
Assert::same(array('col' => FALSE), $result->test(array('col' => 0.0)));
Assert::same(array('col' => TRUE), $result->test(array('col' => 1)));
Assert::same(array('col' => TRUE), $result->test(array('col' => 1.0)));
});
test(function () {
$result = new MockResult;
$result->setType('col', dibi::TEXT); // means TEXT or UNKNOWN
Assert::same(array('col' => NULL), $result->test(array('col' => NULL)));
Assert::same(array('col' => TRUE), $result->test(array('col' => TRUE)));
Assert::same(array('col' => FALSE), $result->test(array('col' => FALSE)));
Assert::same(array('col' => ''), $result->test(array('col' => '')));
Assert::same(array('col' => '0'), $result->test(array('col' => '0')));
Assert::same(array('col' => '1'), $result->test(array('col' => '1')));
Assert::same(array('col' => 0), $result->test(array('col' => 0)));
Assert::same(array('col' => 1), $result->test(array('col' => 1)));
});
test(function () {
$result = new MockResult;
$result->setType('col', dibi::FLOAT);
Assert::same(array('col' => NULL), $result->test(array('col' => NULL)));
Assert::same(array('col' => 1.0), $result->test(array('col' => TRUE)));
Assert::same(array('col' => 0.0), $result->test(array('col' => FALSE)));
Assert::same(array('col' => 0.0), $result->test(array('col' => '')));
Assert::same(array('col' => 0.0), $result->test(array('col' => '0')));
Assert::same(array('col' => 1.0), $result->test(array('col' => '1')));
Assert::same(array('col' => 0.0), $result->test(array('col' => '.0')));
Assert::same(array('col' => 0.1), $result->test(array('col' => '.1')));
Assert::same(array('col' => 0.0), $result->test(array('col' => '0.0')));
Assert::same(array('col' => 0.1), $result->test(array('col' => '0.1')));
Assert::same(array('col' => 0.0), $result->test(array('col' => '0.000')));
Assert::same(array('col' => 0.1), $result->test(array('col' => '0.100')));
Assert::same(array('col' => 1.0), $result->test(array('col' => '1.0')));
Assert::same(array('col' => 1.1), $result->test(array('col' => '1.1')));
Assert::same(array('col' => 1.0), $result->test(array('col' => '1.000')));
Assert::same(array('col' => 1.1), $result->test(array('col' => '1.100')));
Assert::same(array('col' => 1.0), $result->test(array('col' => '001.000')));
Assert::same(array('col' => 1.1), $result->test(array('col' => '001.100')));
Assert::same(array('col' => 10.0), $result->test(array('col' => '10')));
Assert::same(array('col' => 11.0), $result->test(array('col' => '11')));
Assert::same(array('col' => 10.0), $result->test(array('col' => '0010')));
Assert::same(array('col' => 11.0), $result->test(array('col' => '0011')));
Assert::same(array('col' => '0.00000000000000000001'), $result->test(array('col' => '0.00000000000000000001')));
Assert::same(array('col' => '12345678901234567890'), $result->test(array('col' => '12345678901234567890')));
Assert::same(array('col' => '12345678901234567890'), $result->test(array('col' => '012345678901234567890')));
Assert::same(array('col' => '12345678901234567890'), $result->test(array('col' => '12345678901234567890.000')));
Assert::same(array('col' => '12345678901234567890.1'), $result->test(array('col' => '012345678901234567890.100')));
Assert::same(array('col' => 0.0), $result->test(array('col' => 0)));
Assert::same(array('col' => 0.0), $result->test(array('col' => 0.0)));
Assert::same(array('col' => 1.0), $result->test(array('col' => 1)));
Assert::same(array('col' => 1.0), $result->test(array('col' => 1.0)));
setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'deu_deu');
Assert::same(array('col' => 0.0), $result->test(array('col' => '')));
Assert::same(array('col' => 0.0), $result->test(array('col' => '0')));
Assert::same(array('col' => 1.0), $result->test(array('col' => '1')));
Assert::same(array('col' => 0.0), $result->test(array('col' => '.0')));
Assert::same(array('col' => 0.1), $result->test(array('col' => '.1')));
Assert::same(array('col' => 0.0), $result->test(array('col' => '0.0')));
Assert::same(array('col' => 0.1), $result->test(array('col' => '0.1')));
Assert::same(array('col' => 0.0), $result->test(array('col' => '0.000')));
Assert::same(array('col' => 0.1), $result->test(array('col' => '0.100')));
Assert::same(array('col' => 1.0), $result->test(array('col' => '1.0')));
Assert::same(array('col' => 1.1), $result->test(array('col' => '1.1')));
Assert::same(array('col' => 1.0), $result->test(array('col' => '1.000')));
Assert::same(array('col' => 1.1), $result->test(array('col' => '1.100')));
Assert::same(array('col' => 1.0), $result->test(array('col' => '001.000')));
Assert::same(array('col' => 1.1), $result->test(array('col' => '001.100')));
Assert::same(array('col' => 10.0), $result->test(array('col' => '10')));
Assert::same(array('col' => 11.0), $result->test(array('col' => '11')));
Assert::same(array('col' => 10.0), $result->test(array('col' => '0010')));
Assert::same(array('col' => 11.0), $result->test(array('col' => '0011')));
Assert::same(array('col' => '0.00000000000000000001'), $result->test(array('col' => '0.00000000000000000001')));
Assert::same(array('col' => '12345678901234567890'), $result->test(array('col' => '12345678901234567890')));
Assert::same(array('col' => '12345678901234567890'), $result->test(array('col' => '012345678901234567890')));
Assert::same(array('col' => '12345678901234567890'), $result->test(array('col' => '12345678901234567890.000')));
Assert::same(array('col' => '12345678901234567890.1'), $result->test(array('col' => '012345678901234567890.100')));
Assert::same(array('col' => 0.0), $result->test(array('col' => 0)));
Assert::same(array('col' => 0.0), $result->test(array('col' => 0.0)));
Assert::same(array('col' => 1.0), $result->test(array('col' => 1)));
Assert::same(array('col' => 1.0), $result->test(array('col' => 1.0)));
setlocale(LC_NUMERIC, 'C');
});

View File

@@ -160,7 +160,7 @@ if ($config['system'] === 'odbc') {
Assert::same(
reformat(array(
'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)
@@ -199,7 +199,7 @@ $args = array(
"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');
@@ -302,7 +302,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

@@ -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

@@ -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->table->name);
Assert::same('s', $column->type);
Assert::type('string', $column->nativeType);
Assert::same(100, $column->size);
Assert::true($column->nullable);
Assert::false($column->nullable);
Assert::false($column->autoIncrement);
//Assert::null($column->default);