Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# v8.3.0 (2024-09-02)

- add support for invisible columns (#240)
- add support for change streams using Blueprint (#230)
- add support for snapshot queries (#215)
- deprecate Connection::getDatabaseContext() and move logic to UseMutations::getMutationExecutor() (#227)
Expand Down
16 changes: 15 additions & 1 deletion src/Schema/Grammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Grammar extends BaseGrammar
/**
* @inheritdoc
*/
protected $modifiers = ['Nullable', 'Default', 'UseSequence'];
protected $modifiers = ['Nullable', 'Default', 'Invisible', 'UseSequence'];

/**
* Compile the query to determine the tables.
Expand Down Expand Up @@ -733,6 +733,20 @@ protected function typeBoolean(Fluent $column)
return 'bool';
}

/**
* Get the SQL for an invisible column modifier.
*
* @param Blueprint $blueprint
* @param ColumnDefinition&object{ invisible: bool } $column
* @return string|null
*/
protected function modifyInvisible(Blueprint $blueprint, Fluent $column)
{
return $column->invisible !== null
? ' hidden'
: null;
}

/**
* @param Blueprint $blueprint
* @param IntColumnDefinition $column
Expand Down
24 changes: 24 additions & 0 deletions tests/Schema/BlueprintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,30 @@ public function test_composite_primary_key(): void
], $statements);
}

public function test_invisible_columns(): void
{
$conn = $this->getDefaultConnection();
$grammar = new Grammar();
$tableName = $this->generateTableName('Invisible');

$blueprint = new Blueprint($tableName, function (Blueprint $table) {
$table->create();
$table->integer('id')->primary();
$table->string('name')->nullable()->invisible();
});

$this->assertSame([
"create table `{$tableName}` (`id` int64 not null, `name` string(255) hidden) primary key (`id`)",
], $blueprint->toSql($conn, $grammar));

$blueprint->build($conn, $grammar);

$conn->table($tableName)->insert(['id' => 1, 'name' => 'test']);
$row = $conn->table($tableName)->first();
$this->assertArrayHasKey('id', $row);
$this->assertArrayNotHasKey('name', $row);
}

public function test_interleaving(): void
{
$conn = $this->getDefaultConnection();
Expand Down
Loading