Skip to content

Commit 5050e41

Browse files
committed
fixed compiling exclude command
1 parent 4a4b24b commit 5050e41

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

docker/Dockerfile-php

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM php:7-cli
1+
FROM php:8-cli
22

33
RUN apt-get update -yqq \
44
&& apt-get install git zlib1g-dev libpq-dev libzip-dev -y \
@@ -9,3 +9,5 @@ RUN curl -fsSL https://getcomposer.org/installer | php \
99

1010
RUN pecl install xdebug \
1111
&& docker-php-ext-enable xdebug
12+
13+
RUN echo "xdebug.mode=coverage,debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

phpunit.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
33
<coverage>
44
<include>
55
<directory suffix=".php">src/</directory>

src/Macros/BluePrintMacros.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function register(): void
2727

2828
Blueprint::macro('excludeRangeOverlapping', function ($columnName, ...$additionalColumns) {
2929
return $this->addCommand('excludeRangeOverlapping', [
30-
'column' => $columnName,
30+
'range_column' => $columnName,
3131
'additionalColumns' => $additionalColumns,
3232
]);
3333
});

src/PostgresGrammarWithRangeTypes.php

+12-8
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,20 @@ public function getFluentCommands(): array
9999
* @param Fluent $command
100100
* @return string
101101
*/
102-
public function compileExcludeRangeOverlapping(Blueprint $blueprint, Fluent $command): string
102+
public function compileExcludeRangeOverlapping(Blueprint $blueprint, Fluent $command): ?string
103103
{
104+
if (!$command->range_column){
105+
return null;
106+
}
107+
104108
if (! empty($command->additionalColumns)) {
105109
$this->addBtreeGistExtension();
106110
}
107111

108112
return sprintf('alter table %s add exclude using gist (%s %s with &&)',
109113
$this->wrapTable($blueprint),
110114
$this->getAdditionalColumnsForExclude($command->additionalColumns),
111-
$this->wrap($command->column)
115+
$this->wrap($command->range_column)
112116
);
113117
}
114118

@@ -117,16 +121,16 @@ protected function addBtreeGistExtension(): void
117121
DB::statement('CREATE EXTENSION IF NOT EXISTS btree_gist;');
118122
}
119123

120-
/**
121-
* @param array|null $additionalColumns
122-
* @return string
123-
*/
124-
private function getAdditionalColumnsForExclude(?array $additionalColumns): string
124+
private function getAdditionalColumnsForExclude(?array $additionalColumns = []): string
125125
{
126+
if (!is_array($additionalColumns)){
127+
return '';
128+
}
129+
126130
$columns = '';
127131

128132
foreach ($additionalColumns as $additionalColumn) {
129-
$columns .= "{$additionalColumn} WITH =,";
133+
$columns .= "$additionalColumn WITH =,";
130134
}
131135

132136
return $columns;

0 commit comments

Comments
 (0)