passport icon indicating copy to clipboard operation
passport copied to clipboard

Data type mismatch on laravel 11 sqlite database

Open Blackart-glitch opened this issue 1 year ago • 3 comments
trafficstars

Passport Version

12.2.0

Laravel Version

11.7.0

PHP Version

8.2.14

Database Driver & Version

Sqlite

Description

When attempting to use Laravel Passport's php artisan passport:install or php artisan passport:client command to create a personal access client, a datatype mismatch error image

SQLSTATE[HY000]: General error: 20 datatype mismatch (Connection: sqlite, SQL: insert into "oauth_clients" ("user_id", "name", "secret", "provider", "redirect", "personal_access_client", "password_client", "revoked", "id", "updated_at", "created_at") values (?, LARAVEL Personal Access Client, $2y$10$p7iQwvrEpbjC6K5gp6SbR.8o10kjrqx3d94BQSN8m4z1roDs56GcO, ?, http://localhost, 1, 0, 0, 9c00e41e-3b6b-4864-903e-bcd8757c7370, 2024-05-09 17:40:11, 2024-05-09 17:40:11))

occurs during the insertion of data into the oauth_clients table. This issue prevents the successful creation of personal access clients. It's a fresh project, not an existing application with all dependencies including composer and linux environment( not sure if thats part of the problem anyway though)

Also, the Question marks for the user_id and providers section got me a little worried so i double checked the migration file. looks good as it accepts nullable value

Original Migration file:

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('oauth_clients', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('user_id')->nullable()->index();
            $table->string('name');
            $table->string('secret', 100)->nullable();
            $table->string('provider')->nullable();
            $table->text('redirect');
            $table->boolean('personal_access_client');
            $table->boolean('password_client');
            $table->boolean('revoked');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('oauth_clients');
    }
};

ive tried inspecting the package itself, still am. so i think i'd just drop this here so anyone who might have come across it can get updates.

Steps To Reproduce

  1. Run the passport:install command on a fresh install of a laravel project using an sqlite (3.45.3) database.
  2. I chose yes for the below

Would you like to create the "personal access" and "password grant" clients? (yes/no) [yes]:

  1. Observe the error message indicating a datatype mismatch during the insertion of data into the oauth_clients table. im not sure if thats the only one but its the first that pops up.

Blackart-glitch avatar May 09 '24 18:05 Blackart-glitch

Laravel 11 does require SQLite 3.35 as minimum requirements: https://laravel.com/docs/11.x/database

crynobone avatar May 09 '24 22:05 crynobone

@crynobone yeah, my system satisfies all of the requirements to implement passport

Blackart-glitch avatar May 10 '24 07:05 Blackart-glitch

Update:

After a series of re-installs and investigations, I have identified the root cause of the issue. The error occurs prominently when attempting to use UUIDs for clients in Laravel Passport. This issue may stem from the table schema itself.

I found that avoiding UUIDs completely resolves the problem. By keeping the

'client_uuids' => false

in the configuration option, in the config/passport.php file. the datatype mismatch error no longer occurs. I'll try tweaking some more parts...let's see what pops up

Blackart-glitch avatar May 10 '24 07:05 Blackart-glitch

Heya. Going to close this one now since there's only been one report and there's a workaround. Should you have any other findings, feel free to post them.

driesvints avatar May 30 '24 07:05 driesvints