Skip to content
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

Don't trim( null ) #15

Merged
merged 6 commits into from
Oct 23, 2023
Merged
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
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

All notable changes to this project will be documented in this file. This project adhere to the [Semantic Versioning](http://semver.org/) standard.

## [1.0.7] 2023-10-23

* Tweak - Updates around `trim()` for php 8.1 compatibility.
* Tweak - Force `From()` and `Select()` to convert passed non-strings to an empty string.

## [1.0.6] 2023-09-05

* Tweak - Fix array shape for errors in `DatabaseQueryException`

## [1.0.5] 2023-09-05

* Tweak - Updating docblock for `whereExists()` and `whereNotExists()` in response to a PHPStan flag.

## [1.0.4] 2023-06-06

* Tweak - Added more documentation for methods provided by DB.
* Tweak - Adjusted docblocks to better declare types.

## [1.0.3] 2022-11-22

* Tweak - Set composer.json `config.platform.php` to `7.0`.
Expand Down
4 changes: 2 additions & 2 deletions src/DB/DB.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ public static function prefix( $tableName ) {
* Create QueryBuilder instance
*
* @param string|RawSQL $table
* @param null|string $alias
* @param string|null $alias
*
* @return QueryBuilder
*/
public static function table( $table, $alias = null ) {
public static function table( $table, $alias = '' ) {
$builder = new QueryBuilder();
$builder->from( $table, $alias );

Expand Down
4 changes: 2 additions & 2 deletions src/DB/QueryBuilder/Clauses/From.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class From {
* @param string|RawSQL $table
* @param string|null $alias
*/
public function __construct( $table, $alias = null ) {
public function __construct( $table, $alias = '' ) {
$this->table = QueryBuilder::prefixTable( $table );
$this->alias = trim( $alias );
$this->alias = is_scalar( $alias ) ? trim( (string) $alias ) : '';
}
}
4 changes: 2 additions & 2 deletions src/DB/QueryBuilder/Clauses/Join.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ class Join {
* @param string $joinType \StellarWP\DB\QueryBuilder\Types\JoinType
* @param string|null $alias
*/
public function __construct( $joinType, $table, $alias = null ) {
public function __construct( $joinType, $table, $alias = '' ) {
$this->table = QueryBuilder::prefixTable( $table );
$this->joinType = $this->getJoinType( $joinType );
$this->alias = trim( $alias );
$this->alias = is_scalar( $alias ) ? trim( (string) $alias ) : '';
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/DB/QueryBuilder/Clauses/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class Select {
* @param string $column
* @param string|null $alias
*/
public function __construct( $column, $alias = null ) {
public function __construct( $column, $alias = '' ) {
$this->column = trim( $column );
$this->alias = trim( $alias );
$this->alias = is_scalar( $alias ) ? trim( (string) $alias ) : '';
}
}
2 changes: 1 addition & 1 deletion src/DB/QueryBuilder/Concerns/FromClause.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ trait FromClause {
*
* @return $this
*/
public function from( $table, $alias = null ) {
public function from( $table, $alias = '' ) {
$this->froms[] = new From( $table, $alias );

return $this;
Expand Down
6 changes: 3 additions & 3 deletions src/DB/QueryBuilder/Concerns/JoinClause.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function join( $callback ) {
*
* @return static
*/
public function leftJoin( $table, $column1, $column2, $alias = null ) {
public function leftJoin( $table, $column1, $column2, $alias = '' ) {
$this->join(
function ( JoinQueryBuilder $builder ) use ( $table, $column1, $column2, $alias ) {
$builder
Expand All @@ -60,7 +60,7 @@ function ( JoinQueryBuilder $builder ) use ( $table, $column1, $column2, $alias
*
* @return static
*/
public function innerJoin( $table, $column1, $column2, $alias = null ) {
public function innerJoin( $table, $column1, $column2, $alias = '' ) {
$this->join(
function ( JoinQueryBuilder $builder ) use ( $table, $column1, $column2, $alias ) {
$builder
Expand All @@ -80,7 +80,7 @@ function ( JoinQueryBuilder $builder ) use ( $table, $column1, $column2, $alias
*
* @return static
*/
public function rightJoin( $table, $column1, $column2, $alias = null ) {
public function rightJoin( $table, $column1, $column2, $alias = '' ) {
$this->join(
function ( JoinQueryBuilder $builder ) use ( $table, $column1, $column2, $alias ) {
$builder
Expand Down
16 changes: 8 additions & 8 deletions src/DB/QueryBuilder/JoinQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ class JoinQueryBuilder {

/**
* @param string|RawSQL $table
* @param null|string $alias
* @param string|null $alias
*
* @return $this
*/
public function leftJoin( $table, $alias = null ) {
public function leftJoin( $table, $alias = '' ) {
return $this->join(
JoinType::LEFT,
$table,
Expand All @@ -33,11 +33,11 @@ public function leftJoin( $table, $alias = null ) {

/**
* @param string|RawSQL $table
* @param null|string $alias
* @param string|null $alias
*
* @return $this
*/
public function rightJoin( $table, $alias = null ) {
public function rightJoin( $table, $alias = '' ) {
return $this->join(
JoinType::RIGHT,
$table,
Expand All @@ -47,11 +47,11 @@ public function rightJoin( $table, $alias = null ) {

/**
* @param string|RawSQL $table
* @param null|string $alias
* @param string|null $alias
*
* @return $this
*/
public function innerJoin( $table, $alias = null ) {
public function innerJoin( $table, $alias = '' ) {
return $this->join(
JoinType::INNER,
$table,
Expand Down Expand Up @@ -122,11 +122,11 @@ public function joinRaw( $sql, ...$args ) {
*
* @param string $joinType
* @param string|RawSQL $table
* @param string $alias
* @param string|null $alias
*
* @return $this
*/
private function join( $joinType, $table, $alias ) {
private function join( $joinType, $table, $alias = '' ) {
$this->joins[] = new Join(
$joinType,
$table,
Expand Down
Loading