Skip to content

Commit

Permalink
Merge branch '4.0.x' into fix/#14862-pgsql-null-columns
Browse files Browse the repository at this point in the history
# Conflicts:
#	tests/_data/assets/schemas/pgsql.sql
#	tests/_data/fixtures/Migrations/OrdersProductsMigration.php
#	tests/_envs/pgsql.yml
  • Loading branch information
Jeckerson committed Feb 26, 2020
2 parents 4015877 + 2ce20b7 commit a4b3b63
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 45 deletions.
42 changes: 18 additions & 24 deletions tests/_data/assets/schemas/pgsql.sql
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@


drop table if exists co_customers;

create table co_customers
(
cst_id serial not null constraint co_customers_pk primary key,
cst_status_flag smallint null,
cst_name_last varchar(100) null,
cst_name_first varchar(50) null
);

create index co_customers_cst_status_flag_index
on co_customers (cst_status_flag);

create index co_customers_cst_name_last_index
on co_customers (cst_name_last);

create index co_customers_cst_name_first_index
on co_customers (cst_name_first);



drop table if exists co_invoices;

create table co_invoices
(
inv_id serial not null constraint co_invoices_pk primary key,
Expand All @@ -32,59 +32,53 @@ create table co_invoices
inv_total numeric(10, 2),
inv_created_at timestamp
);

create index co_invoices_inv_created_at_index
on co_invoices (inv_created_at);

create index co_invoices_inv_cst_id_index
on co_invoices (inv_cst_id);

create index co_invoices_inv_status_flag_index
on co_invoices (inv_status_flag);





drop table if exists co_orders;


drop table if exists co_orders;

create table co_orders
(
ord_id serial not null
constraint ord_pk
primary key,
ord_name varchar(70)
);

alter table public.co_orders owner to postgres;




drop table if exists public.co_orders_x_products;

create table public.co_orders_x_products
(
oxp_ord_id int not null,
oxp_prd_id int not null,
oxp_quantity int not null
);

alter table public.co_orders_x_products owner to postgres;



drop table if exists co_products;


drop table if exists co_products;

create table co_products
(
prd_id serial not null
constraint prd_pk
primary key,
prd_name varchar(70)
);

alter table public.co_products owner to postgres;





Expand Down
3 changes: 1 addition & 2 deletions tests/_data/fixtures/Migrations/InvoicesMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ public function insert(
insert into co_invoices (
inv_id, inv_cst_id, inv_status_flag, inv_title, inv_total, inv_created_at
) values (
{$id}, {$custId}, {$status}, "{$title}", {$total}, "{$now}"
{$id}, {$custId}, {$status}, '{$title}', {$total}, '{$now}'
)
SQL;

return $this->connection->exec($sql);
}

Expand Down
3 changes: 0 additions & 3 deletions tests/_data/fixtures/Migrations/OrdersMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ protected function getSqlPgsql(): array
primary key,
ord_name varchar(70)
);
",
"
alter table public.co_orders owner to postgres;
"
];
}
Expand Down
7 changes: 2 additions & 5 deletions tests/_data/fixtures/Migrations/OrdersProductsMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,15 @@ protected function getSqlPgsql(): array
{
return [
"
drop table if exists public.co_orders_x_products;
drop table if exists private.co_orders_x_products;
",
"
create table public.co_orders_x_products
create table private.co_orders_x_products
(
oxp_ord_id int not null,
oxp_prd_id int not null,
oxp_quantity int not null
);
",
"
alter table public.co_orders_x_products owner to postgres;
"
];
}
Expand Down
3 changes: 0 additions & 3 deletions tests/_data/fixtures/Migrations/ProductsMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ protected function getSqlPgsql(): array
primary key,
prd_name varchar(70)
);
",
"
alter table public.co_products owner to postgres;
"
];
}
Expand Down
2 changes: 2 additions & 0 deletions tests/_envs/pgsql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ modules:
cleanup: false
reconnect: true
waitlock: 10
initial_queries:
- 'CREATE SCHEMA IF NOT EXISTS private;'
3 changes: 2 additions & 1 deletion tests/database/Db/Adapter/Pdo/QueryCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ public function _before(DatabaseTester $I)
* @author Phalcon Team <team@phalcon.io>
* @since 2020-02-22
*
* @group pgsql
* @group mysql
* @group sqlite
*/
public function dbAdapterPdoQuery(DatabaseTester $I)
{
$I->wantToTest('Db\Adapter\Pdo\Mysql - query()');
$I->wantToTest('Db\Adapter\Pdo - query()');

$connection = $I->getConnection();
$db = $this->container->get('db');
Expand Down
15 changes: 8 additions & 7 deletions tests/database/Mvc/Model/Criteria/JoinCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Phalcon\Test\Models\Invoices;
use Phalcon\Test\Models\Orders;
use Phalcon\Test\Models\Products;
use Phalcon\Mvc\Model\Resultset\Simple;

/**
* Class JoinCest
Expand Down Expand Up @@ -74,6 +75,7 @@ public function mvcModelCriteriaJoin(DatabaseTester $I)
* @since 2020-02-06
*
* @group mysql
* @group pgsql
*/
public function mvcModelCriteriaJoinManyToManyMultipleSchema(DatabaseTester $I)
{
Expand All @@ -92,13 +94,12 @@ public function mvcModelCriteriaJoinManyToManyMultipleSchema(DatabaseTester $I)
$builder->from(Orders::class);
$builder->join(Products::class);

$expected = 'SELECT `co_orders`.`ord_id`, `co_orders`.`ord_name` '
. 'FROM `co_orders` '
. 'INNER JOIN `private`.`co_orders_x_products` '
. 'ON `co_orders`.`ord_id` = `co_orders_x_products`.`oxp_ord_id` '
. 'INNER JOIN `co_products` ON `co_orders_x_products`.`oxp_prd_id` = `co_products`.`prd_id`';
$actual = $builder->getQuery()->getSql();
$expected = 'private';
$query = $builder->getQuery();
$request = $query->getSql();

$I->assertEquals($expected, $actual['sql']);
$I->assertContains($expected, $request['sql']);

$I->assertInstanceOf(Simple::class, $query->execute());
}
}

0 comments on commit a4b3b63

Please sign in to comment.