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

Migration generator not add precision and scale params for decimal column type in Embeddable class 🐛 #102

Open
1 task done
ncodealex opened this issue Jun 23, 2024 · 3 comments
Assignees
Labels
status:to be verified Needs to be reproduced and validated. type:bug Bug

Comments

@ncodealex
Copy link

No duplicates 🥲.

  • I have searched for a similar issue in our bug tracker and didn't find any solutions.

What happened?

Hello ! Thanks for your product !

I'm create embeddable class for my base entity.

#[Embeddable(columnPrefix: 'property_')]
final class ProductProperty
{
    #[Column(type: 'decimal', nullable: false, default: 0, precision: 2, scale: 10)]
    private int $width = 0;
    
    // and others columns

}

When i generate migration file with the command:

php app.php cycle:migrate

I get such a file that does not include params precision and scale params:

// Parent entity 
final class Product
{
    #[Column(type: 'decimal', nullable: true, precision: 2, scale: 2)]
    private int $minStock = 0;

    #[Embedded(target: 'ProductProperty')]
    private ProductProperty $property;
    
    public function __construct(){
        $this->property = new ProductProperty();
    }
}

// Generated migration for 'Product'

class OrmDefault503ad0138adb712888e44c220d4cf5aa extends Migration
{

    public function up(): void
    {
        $this->table('product')
->addColumn('min_stock', 'decimal', ['nullable' => true, 'defaultValue' => null, 'precision' => 2, 'scale' => 2]); /// This property in base entity
->addColumn('property_width', 'decimal', ['nullable' => false, 'defaultValue' => 0, 'precision' => 0, 'scale' => 0]) // And this in Embedded entity 
     }

}

I will be grateful for your help!

Version

annotated v4.1.0, orm v2.8.1, PHP 8.3

ORM Schema

No response

@ncodealex ncodealex added status:to be verified Needs to be reproduced and validated. type:bug Bug labels Jun 23, 2024
@ncodealex
Copy link
Author

ncodealex commented Jun 23, 2024

if i add parameters with attributes we get same behavior

    
    #[Column(type: 'decimal', nullable: false, default: 0, attributes: ['precision' => 3, 'scale' => 11])]
    private int $width = 0;
    

@roxblnfk
Copy link
Member

roxblnfk commented Jun 23, 2024

could you try #[Column(type: 'decimal(3,11)')]?

@ncodealex
Copy link
Author

could you try #[Column(type: 'decimal(3,11)')]?

This work !

Will be generated:

->addColumn('property_width', 'decimal', ['nullable' => false, 'defaultValue' => 0, 'precision' => 3, 'scale' => 11])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:to be verified Needs to be reproduced and validated. type:bug Bug
Projects
Status: Todo
Development

No branches or pull requests

2 participants