Skip to content

Tests for distinctOn() and selectDistinct() guard #301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

Ouzo is a PHP MVC framework with built-in ORM and util libraries. PHP 8.0 or later is required.

[![Build Status](https://travis-ci.org/letsdrink/ouzo.png?branch=master)](https://travis-ci.org/letsdrink/ouzo)
[![Build Status](https://github.com/letsdrink/ouzo/workflows/build/badge.svg?branch=master)](https://github.com/letsdrink/ouzo/actions)
[![Documentation Status](https://readthedocs.org/projects/ouzo/badge/?version=latest)](https://readthedocs.org/projects/ouzo/?badge=latest)
[![Coverage Status](https://coveralls.io/repos/letsdrink/ouzo/badge.svg?branch=master)](https://coveralls.io/r/letsdrink/ouzo?branch=master)
Expand Down
32 changes: 32 additions & 0 deletions test/src/Ouzo/Core/Db/ModelQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,38 @@ public function shouldReturnDistinctOnResults()
$this->assertEquals('john', $products[1]->description);
}

/**
* @test
* @group postgres
*/
public function shouldFailForDistinctOnAndSelectDistinct()
{
// then
$this->expectException(DbException::class);
$this->expectExceptionMessage('Cannot use DISTINCT together with DISTINCT ON');
// when
Product::where()
->distinctOn(['description'])
->selectDistinct(['description'])
->fetchAll();
}

/**
* @test
* @group postgres
*/
public function shouldFailForSelectDistinctAndDistinctOn()
{
// then
$this->expectException(DbException::class);
$this->expectExceptionMessage('Cannot use DISTINCT together with DISTINCT ON');
// when
Product::where()
->selectDistinct(['description'])
->distinctOn(['description'])
->fetchAll();
}

/**
* @test
*/
Expand Down