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

[11.x] Add length to binary method #50355

Merged
merged 2 commits into from
Mar 4, 2024

Conversation

hafezdivandari
Copy link
Contributor

@hafezdivandari hafezdivandari commented Mar 4, 2024

This PR adds support for binary(n) and varbinary(n) column types on databases that support this type (MySQL, MariaDB and SQL Server).

PS: No upgrade guide entry is needed.

Usage

Schema::binary('test', function (Blueprint $table) {
    $table->binary('blob_column'); // no change
    // `BLOB` on MySQL, MariaDB, and SQLite, `BYTEA` on PostgreSQL, `VARBINARY(MAX)` on SQL Server

    $table->binary('varbinary_column', length: 16);
    // `VARBINARY(16)` on MySQL, MariaDB, and SQL Server, `BLOB` on SQLite, `BYTEA` on PostgreSQL

    $table->binary('binary_column', length: 16, fixed: true);
    // `BINARY(16)` on MySQL, MariaDB, and SQL Server, `BLOB` on SQLite, `BYTEA` on PostgreSQL
});
Syntax MySQL / MariaDB SQL Server SQLite PostgreSQL
binary('name') BLOB VARBINARY(MAX) BLOB BYTEA
binary('name', length: 16) VARBINARY(16) VARBINARY(16) BLOB BYTEA
binary('name', length: 16, fixed: true) BINARY(16) BINARY(16) BLOB BYTEA

@taylorotwell taylorotwell merged commit 12cbfa5 into laravel:master Mar 4, 2024
25 of 28 checks passed
@hafezdivandari hafezdivandari deleted the master-binary-length branch March 4, 2024 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants