fix: Use integer for variant and category ranks (#7572)
This commit is contained in:
1 parent
97327670a5
commit
3ede9d7863
6 files changed
+68
-43
No files matched your search
+19
-19
@@ -314,7 +314,7 @@ moduleIntegrationTestRunner({
|
|||||||
mpath:
|
mpath:
|
||||||
"electronics.computers.laptops.gaming-laptops.high-performance.",
|
"electronics.computers.laptops.gaming-laptops.high-performance.",
|
||||||
parent_category_id: "gaming-laptops",
|
parent_category_id: "gaming-laptops",
|
||||||
category_children: [
|
category_children: expect.arrayContaining([
|
||||||
{
|
{
|
||||||
id: "4k-gaming",
|
id: "4k-gaming",
|
||||||
handle: "4k-gaming-laptops",
|
handle: "4k-gaming-laptops",
|
||||||
@@ -331,7 +331,7 @@ moduleIntegrationTestRunner({
|
|||||||
parent_category_id: "high-performance",
|
parent_category_id: "high-performance",
|
||||||
category_children: [],
|
category_children: [],
|
||||||
},
|
},
|
||||||
],
|
]),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -900,10 +900,10 @@ moduleIntegrationTestRunner({
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(productCategory).toEqual(
|
expect(JSON.parse(JSON.stringify(productCategory))).toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
name: "New Category",
|
name: "New Category",
|
||||||
rank: "0",
|
rank: 0,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -932,7 +932,7 @@ moduleIntegrationTestRunner({
|
|||||||
expect(productCategoryNew).toEqual(
|
expect(productCategoryNew).toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
name: "New Category 2",
|
name: "New Category 2",
|
||||||
rank: "1",
|
rank: 1,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -954,7 +954,7 @@ moduleIntegrationTestRunner({
|
|||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
name: "New Category 2.1",
|
name: "New Category 2.1",
|
||||||
parent_category_id: productCategoryNew.id,
|
parent_category_id: productCategoryNew.id,
|
||||||
rank: "0",
|
rank: 0,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -1032,15 +1032,15 @@ moduleIntegrationTestRunner({
|
|||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: productCategoryTwo.id,
|
id: productCategoryTwo.id,
|
||||||
rank: "0",
|
rank: 0,
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: productCategoryZero.id,
|
id: productCategoryZero.id,
|
||||||
rank: "1",
|
rank: 1,
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: productCategoryOne.id,
|
id: productCategoryOne.id,
|
||||||
rank: "2",
|
rank: 2,
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
@@ -1065,19 +1065,19 @@ moduleIntegrationTestRunner({
|
|||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: productCategoryTwo.id,
|
id: productCategoryTwo.id,
|
||||||
rank: "0",
|
rank: 0,
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: productCategoryZeroZero.id,
|
id: productCategoryZeroZero.id,
|
||||||
rank: "1",
|
rank: 1,
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: productCategoryZeroOne.id,
|
id: productCategoryZeroOne.id,
|
||||||
rank: "2",
|
rank: 2,
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: productCategoryZeroTwo.id,
|
id: productCategoryZeroTwo.id,
|
||||||
rank: "3",
|
rank: 3,
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
@@ -1102,19 +1102,19 @@ moduleIntegrationTestRunner({
|
|||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: productCategoryTwo.id,
|
id: productCategoryTwo.id,
|
||||||
rank: "0",
|
rank: 0,
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: productCategoryZeroZero.id,
|
id: productCategoryZeroZero.id,
|
||||||
rank: "1",
|
rank: 1,
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: productCategoryZeroOne.id,
|
id: productCategoryZeroOne.id,
|
||||||
rank: "2",
|
rank: 2,
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: productCategoryZeroTwo.id,
|
id: productCategoryZeroTwo.id,
|
||||||
rank: "3",
|
rank: 3,
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
@@ -1182,11 +1182,11 @@ moduleIntegrationTestRunner({
|
|||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: productCategoryZero.id,
|
id: productCategoryZero.id,
|
||||||
rank: "0",
|
rank: 0,
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: productCategoryTwo.id,
|
id: productCategoryTwo.id,
|
||||||
rank: "1",
|
rank: 1,
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
|
|||||||
+16
-16
@@ -281,7 +281,7 @@ moduleIntegrationTestRunner({
|
|||||||
expect(productCategory).toEqual(
|
expect(productCategory).toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
name: "New Category",
|
name: "New Category",
|
||||||
rank: "0",
|
rank: 0,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -324,7 +324,7 @@ moduleIntegrationTestRunner({
|
|||||||
expect(productCategoryNew).toEqual(
|
expect(productCategoryNew).toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
name: "New Category 2",
|
name: "New Category 2",
|
||||||
rank: "1",
|
rank: 1,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -346,7 +346,7 @@ moduleIntegrationTestRunner({
|
|||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
name: "New Category 2.1",
|
name: "New Category 2.1",
|
||||||
parent_category_id: productCategoryNew.id,
|
parent_category_id: productCategoryNew.id,
|
||||||
rank: "0",
|
rank: 0,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -438,15 +438,15 @@ moduleIntegrationTestRunner({
|
|||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: productCategoryTwo.id,
|
id: productCategoryTwo.id,
|
||||||
rank: "0",
|
rank: 0,
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: productCategoryZero.id,
|
id: productCategoryZero.id,
|
||||||
rank: "1",
|
rank: 1,
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: productCategoryOne.id,
|
id: productCategoryOne.id,
|
||||||
rank: "2",
|
rank: 2,
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
@@ -471,19 +471,19 @@ moduleIntegrationTestRunner({
|
|||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: productCategoryTwo.id,
|
id: productCategoryTwo.id,
|
||||||
rank: "0",
|
rank: 0,
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: productCategoryZeroZero.id,
|
id: productCategoryZeroZero.id,
|
||||||
rank: "1",
|
rank: 1,
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: productCategoryZeroOne.id,
|
id: productCategoryZeroOne.id,
|
||||||
rank: "2",
|
rank: 2,
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: productCategoryZeroTwo.id,
|
id: productCategoryZeroTwo.id,
|
||||||
rank: "3",
|
rank: 3,
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
@@ -508,19 +508,19 @@ moduleIntegrationTestRunner({
|
|||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: productCategoryTwo.id,
|
id: productCategoryTwo.id,
|
||||||
rank: "0",
|
rank: 0,
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: productCategoryZeroZero.id,
|
id: productCategoryZeroZero.id,
|
||||||
rank: "1",
|
rank: 1,
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: productCategoryZeroOne.id,
|
id: productCategoryZeroOne.id,
|
||||||
rank: "2",
|
rank: 2,
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: productCategoryZeroTwo.id,
|
id: productCategoryZeroTwo.id,
|
||||||
rank: "3",
|
rank: 3,
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
@@ -600,11 +600,11 @@ moduleIntegrationTestRunner({
|
|||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: productCategoryZero.id,
|
id: productCategoryZero.id,
|
||||||
rank: "0",
|
rank: 0,
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: productCategoryTwo.id,
|
id: productCategoryTwo.id,
|
||||||
rank: "1",
|
rank: 1,
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -74,13 +74,13 @@
|
|||||||
},
|
},
|
||||||
"rank": {
|
"rank": {
|
||||||
"name": "rank",
|
"name": "rank",
|
||||||
"type": "numeric",
|
"type": "integer",
|
||||||
"unsigned": false,
|
"unsigned": false,
|
||||||
"autoincrement": false,
|
"autoincrement": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"nullable": false,
|
"nullable": false,
|
||||||
"default": "0",
|
"default": "0",
|
||||||
"mappedType": "decimal"
|
"mappedType": "integer"
|
||||||
},
|
},
|
||||||
"parent_category_id": {
|
"parent_category_id": {
|
||||||
"name": "parent_category_id",
|
"name": "parent_category_id",
|
||||||
@@ -1378,13 +1378,13 @@
|
|||||||
},
|
},
|
||||||
"variant_rank": {
|
"variant_rank": {
|
||||||
"name": "variant_rank",
|
"name": "variant_rank",
|
||||||
"type": "numeric",
|
"type": "integer",
|
||||||
"unsigned": false,
|
"unsigned": false,
|
||||||
"autoincrement": false,
|
"autoincrement": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"nullable": true,
|
"nullable": true,
|
||||||
"default": "0",
|
"default": "0",
|
||||||
"mappedType": "decimal"
|
"mappedType": "integer"
|
||||||
},
|
},
|
||||||
"product_id": {
|
"product_id": {
|
||||||
"name": "product_id",
|
"name": "product_id",
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { Migration } from "@mikro-orm/migrations"
|
||||||
|
|
||||||
|
export class Migration20240601111544 extends Migration {
|
||||||
|
async up(): Promise<void> {
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "product_category" alter column "rank" type integer using ("rank"::integer);'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "product_variant" alter column "variant_rank" type integer using ("variant_rank"::integer);'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(): Promise<void> {
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "product_category" alter column "rank" type numeric using ("rank"::numeric);'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "product_variant" alter column "variant_rank" type numeric using ("variant_rank"::numeric);'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -68,7 +68,11 @@ class ProductCategory {
|
|||||||
@Property({ columnType: "boolean", default: false })
|
@Property({ columnType: "boolean", default: false })
|
||||||
is_internal?: boolean
|
is_internal?: boolean
|
||||||
|
|
||||||
@Property({ columnType: "numeric", nullable: false, default: 0 })
|
@Property({
|
||||||
|
columnType: "integer",
|
||||||
|
nullable: false,
|
||||||
|
default: 0,
|
||||||
|
})
|
||||||
rank?: number
|
rank?: number
|
||||||
|
|
||||||
@ManyToOne(() => ProductCategory, {
|
@ManyToOne(() => ProductCategory, {
|
||||||
|
|||||||
@@ -130,12 +130,10 @@ class ProductVariant {
|
|||||||
@Property({ columnType: "jsonb", nullable: true })
|
@Property({ columnType: "jsonb", nullable: true })
|
||||||
metadata?: Record<string, unknown> | null
|
metadata?: Record<string, unknown> | null
|
||||||
|
|
||||||
// TODO: replace with BigNumber, or in this case a normal int should work
|
|
||||||
@Property({
|
@Property({
|
||||||
columnType: "numeric",
|
columnType: "integer",
|
||||||
nullable: true,
|
nullable: true,
|
||||||
default: 0,
|
default: 0,
|
||||||
serializer: optionalNumericSerializer,
|
|
||||||
})
|
})
|
||||||
variant_rank?: number | null
|
variant_rank?: number | null
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user