-
Notifications
You must be signed in to change notification settings - Fork 11
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
[Bug] Fails to work on string ids such as UUID #28
Comments
Hello there! Thanks for opening your first issue on this repo! Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that. Backpack communication channels:
Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch. Thank you! -- |
Based on the information provided in your question and the knowledge sources available, it appears that you're experiencing an issue with Backpack CRUD when using UUID as the primary key for your User model. This problem is related to how Backpack handles non-integer primary keys, particularly UUIDs. The error you're encountering suggests that there's a mismatch between the expected data type for the To resolve this issue, you need to make sure that Backpack correctly handles UUID primary keys. Here are a few steps you can try:
protected $keyType = 'string';
public $incrementing = false;
$table->uuid('id')->primary();
Unfortunately, the knowledge sources don't provide a specific solution for this exact issue with the Revise operation and UUID primary keys. However, there are some related issues that have been addressed in the past:
If these steps don't resolve your issue, you may need to dig deeper into how the Revise operation is interacting with your User model and possibly customize it to handle UUID primary keys correctly. Consider opening a new issue on the Backpack GitHub repository with your specific implementation details, as this might be a bug that needs to be addressed by the Backpack team. ℹ️ Please note our AI Bot does not reply to follow-ups, this will be the only AI answer in this thread. If the AI helped you find the answer, please mark it as answered or write details below so it can learn. Then close the conversation. If not, please give more information for when a human reads this. ℹ️ Relevant sources: Github Issue (closed): [Bug] |
Hey @doncadavona Your efforts show you already know the issue is in the Can you explain what change exactly you are looking for in the backpack? |
Hi @karandatwani92 , I managed to solve the issue by publishing the database migration class ( $table->uuid('revisionable_id');
$table->uuid('user_id')->nullable(); from: $table->unsignedBigInteger('revisionable_id');
$table->unsignedBigInteger('user_id')->nullable(); What I was looking for exactly was a way to implement UUID/ULID with minimal effort as much as possible, where I don't have to touch other packages' files, especially for this common use case (I believe). I am also thinking we may be able to document this common use case for UUID/ULID, say for example let's add in the following note in the docs (https://backpackforlaravel.com/docs/6.x/crud-operation-revisions): NOTICE When using UUID or ULID primary keys for your models, make sure that the Schema::create('revisions', function ($table) {
$table->bigIncrements('id');
$table->string('revisionable_type');
// Original
//$table->unsignedBigInteger('revisionable_id');
//$table->unsignedBigInteger('user_id')->nullable();
// When using UUID
$table->uuid('revisionable_id');
$table->uuid('user_id')->nullable();
// When using ULID
//$table->ulid('revisionable_id');
//$table->ulid('user_id')->nullable();
$table->string('key');
$table->text('old_value')->nullable();
$table->text('new_value')->nullable();
$table->timestamps();
$table->index(['revisionable_id', 'revisionable_type']);
}); |
Bug report
What I did
Implemented Revice on My UserCrudController
What I expected to happen
I should be able to edit a user entry.
What happened
When I save the user entry, this error occurs:
What I've already tried to fix it
I have only gone through reading issues in https://github.com/VentureCraft/revisionable, which seem to be inactive.
This particular issue discusses the issue, but is unresponded to by the developers:
VentureCraft/revisionable#191
I have seen that https://github.com/joshbrw/revisionable-uuid resolves the issue.
Backpack, Laravel, PHP, DB version
When I run
php artisan backpack:version
the output is:The text was updated successfully, but these errors were encountered: