-
Notifications
You must be signed in to change notification settings - Fork 5
feat(customizable): add autoTransform functionality to parseValue methods #20
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
feat(customizable): add autoTransform functionality to parseValue methods #20
Conversation
river0825
commented
Nov 28, 2024
- Implemented validation for string, integer, and float types in custom fields.
- Updated the getValidationRule method in relevant custom field classes.
- Added tests to ensure validation works as expected.
…hods - Implemented validation for string, integer, and float types in custom fields. - Updated the getValidationRule method in relevant custom field classes. - Added tests to ensure validation works as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r+
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r+, with questions.
{ | ||
$rules = ['string']; | ||
if (!$autoTransform) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ 所以 Text type 會變成儲存 any type 只是最後會轉成 string 出去而已嗎
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是的
當傳 integer 進來會出錯就是這個 rule 的檢查,如果拿掉這個 rule 之後就不會出錯了
@@ -14,7 +14,7 @@ | |||
public function up() | |||
{ | |||
Schema::table('users', function (Blueprint $table) { | |||
$table->unsignedBigInteger('account_id'); | |||
$table->unsignedBigInteger('account_id')->nullable(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ 這邊 nullable 的原因是什麼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test fail, so I have to set this field nullable to pass the tests
4) OnrampLab\CustomFields\Tests\Unit\Concerns\CustomizableAutoTransformTest::custom_load_custom_field_values_should_work with data set "Integer field" ('integer', '42', 42, true, '')
Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1 Cannot add a NOT NULL column with default value NULL (SQL: alter table "users" add column "account_id" integer not null)
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:712
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:672
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:502
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php:109
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:364
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:211
/var/www/html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:261
/var/www/html/tests/Migrations/2023_05_30_000155_add_account_id_to_users_table.php:18
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:472
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:394
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:403
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:202
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:167
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:112
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:86
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:606
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:98
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/Util.php:40
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php:653
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php:136
/var/www/html/vendor/symfony/console/Command/Command.php:298
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php:121
/var/www/html/vendor/symfony/console/Application.php:1040
/var/www/html/vendor/symfony/console/Application.php:301
/var/www/html/vendor/symfony/console/Application.php:171
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php:94
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php:186
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:263
/var/www/html/vendor/laravel/framework/src/Illuminate/Testing/PendingCommand.php:260
/var/www/html/vendor/laravel/framework/src/Illuminate/Testing/PendingCommand.php:413
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithConsole.php:66
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:45
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:20
/var/www/html/vendor/orchestra/testbench-core/src/Concerns/Testing.php:170
/var/www/html/vendor/orchestra/testbench-core/src/Concerns/HandlesDatabases.php:59
/var/www/html/vendor/orchestra/testbench-core/src/Concerns/Testing.php:176
/var/www/html/vendor/orchestra/testbench-core/src/TestCase.php:55
/var/www/html/vendor/orchestra/testbench-core/src/Concerns/Testing.php:94
/var/www/html/vendor/orchestra/testbench-core/src/TestCase.php:35
/var/www/html/tests/Unit/Concerns/CustomizableAutoTransformTest.php:18
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r+, thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@river0825 r+ with comments.