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

Data type mismatch on laravel 11 sqlite database #1742

Closed
Blackart-glitch opened this issue May 9, 2024 · 4 comments
Closed

Data type mismatch on laravel 11 sqlite database #1742

Blackart-glitch opened this issue May 9, 2024 · 4 comments

Comments

@Blackart-glitch
Copy link

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.
@crynobone
Copy link
Member

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

@Blackart-glitch
Copy link
Author

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

@Blackart-glitch
Copy link
Author

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

@driesvints
Copy link
Member

driesvints commented May 30, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants