Giter Site home page Giter Site logo

Comments (13)

hiszpek avatar hiszpek commented on July 24, 2024 1

When I tried to use $table->string('id', 255);, when registering a device I had an error about an incorrect value being inserted into column 'id'. What I did was leave it as tinyblob, remove the $table->primary(['id', 'user_id']); fragment, and add a raw statement after creating the table:

DB::statement('ALTER TABLE web_authn_credentials ADD PRIMARY KEY (id(255), user_id)');

Notice the added (255) after id.

Using MySQL 5.7.29

from larapass.

DarkGhostHunter avatar DarkGhostHunter commented on July 24, 2024 1

https://github.com/DarkGhostHunter/Larapass/releases/tag/v3.0.0

from larapass.

DarkGhostHunter avatar DarkGhostHunter commented on July 24, 2024

As this StackOverflow answer, is a problem on MySQL end.

The solution to the problem is to remove the TEXT or BLOB column from the index or unique constraint or set another field as primary key. If you can't do that, and wanting to place a limit on the TEXT or BLOB column, try to use VARCHAR type and place a limit of length on it. By default, VARCHAR is limited to a maximum of 255 characters and its limit must be specified implicitly within a bracket right after its declaration, i.e VARCHAR(200) will limit it to 200 characters long only.

from larapass.

Kehet avatar Kehet commented on July 24, 2024

If MySQL isn't supported, there should be mention about it in readme.

from larapass.

DarkGhostHunter avatar DarkGhostHunter commented on July 24, 2024

Better, I can detect the driver, and if it's MySQL, change the column type to varchar(255).

It will add it next version. In the meantime, you should do the same.

from larapass.

nguyenhiepvan avatar nguyenhiepvan commented on July 24, 2024

You can change it to bigincreasementInteger, and add index to user_id

from larapass.

DarkGhostHunter avatar DarkGhostHunter commented on July 24, 2024

You can change it to bigincreasementInteger, and add index to user_id

An user can have more than 1 credentials. Doing that breaks it.

What the client returns as credential_id is essentially anything. Since it's encoded in BASE64, we can just use binary. Doing an "hey, since MySQL shits its pants on indexing binary keys, I will use a varchar(255) instead" it's not bad but there is a problem when trying to query for a binary string into a text string.

Now, the idea behind a composite primary key is that queries use the credential id and the user_id to identify each row.

I have pushed a fix on dev-master. I don't have access to an MySQL instance, so if anybody can test, I can push it to the next version.

from larapass.

joshrowland avatar joshrowland commented on July 24, 2024

I updated the 2020_04_02_000000_create_web_authn_tables.php file to your new update today and used the php artisan migrate command. It gave this error.
SQLSTATE[42000]: Syntax error or access violation: 1170 BLOB/TEXT column 'id' used in key specification without a key length (SQL: alter table web_authn_credentialsadd primary keyweb_authn_credentials_id_user_id_primary(id, user_id))
and
PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1170 BLOB/TEXT column 'id' used in key specification without a key length")
I'm not familiar with tinyblob to know what it needs.

from larapass.

DarkGhostHunter avatar DarkGhostHunter commented on July 24, 2024

As MySQL says:

  • For indexes on BLOB and TEXT columns, you must specify an index prefix length.

It's the index prefix length. How we do that with Laravel? The docs say to use the static call:

Schema::defaultStringLength(255):

I think 255 should suffice, based on the assumption that no authenticator would push a larger than 255 characters string.

Can someone test this? Again, I'm unable to test on MySQL, at least on the short term.

from larapass.

felipe-machado avatar felipe-machado commented on July 24, 2024

I was able to make it work using

$table->string('id', 255);

As MySQL says:

  • For indexes on BLOB and TEXT columns, you must specify an index prefix length.

It's the index prefix length. How we do that with Laravel? The docs say to use the static call:

Schema::defaultStringLength(255):

I think 255 should suffice, based on the assumption that no authenticator would push a larger than 255 characters string.

Can someone test this? Again, I'm unable to test on MySQL, at least on the short term.

I tried setting the defaultStringLength to 255 but the same error persisted.

from larapass.

nguyenhiepvan avatar nguyenhiepvan commented on July 24, 2024
$table->string('id', 255);

it's work, @DarkGhostHunter i've tried your update in mysql but it got error, because of MySQL assumes 3 bytes per utf8 character. 255 characters is the maximum index size you can specify per column, because 256x3=768, which breaks the 767 byte limit., you should add length of column

from larapass.

DarkGhostHunter avatar DarkGhostHunter commented on July 24, 2024

Okay, I've put an alpha for v3.0.

Check it out for any problems. I'll make a full project with it to test it thoroughly.

from larapass.

DarkGhostHunter avatar DarkGhostHunter commented on July 24, 2024

Fixed, id column now is string VARCHAR. Breaking change. But works on any database.

from larapass.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.