chore(medusa): rm default created at field (#8213)
**What** To maintain the backward compatibility, we use to populate `created_at` no matter what. But since we can break things from v1, I ll remove it as we moved the default ordering to the repository layer
This commit is contained in:
1 parent
f74fdcb644
commit
c307972a99
4 files changed
+7
-15
No files matched your search
@@ -13,7 +13,7 @@ const adminSeeder = require("../../../helpers/admin-seeder")
|
|||||||
const {
|
const {
|
||||||
allowedStoreProductsFields,
|
allowedStoreProductsFields,
|
||||||
defaultStoreProductsRelations,
|
defaultStoreProductsRelations,
|
||||||
} = require("@medusajs/medusa/dist")
|
} = require("@medusajs/medusa")
|
||||||
|
|
||||||
const adminHeaders = {
|
const adminHeaders = {
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -706,15 +706,10 @@ medusaIntegrationTestRunner({
|
|||||||
// TODO: This doesn't work currently, but worked in v1
|
// TODO: This doesn't work currently, but worked in v1
|
||||||
it.skip("returns a list of ordered products by variants prices ASC", async () => {})
|
it.skip("returns a list of ordered products by variants prices ASC", async () => {})
|
||||||
|
|
||||||
// BREAKING: It seems `id` and `created_at` is always returned, even if not in the fields params
|
|
||||||
it("products contain only fields defined with `fields` param", async () => {
|
it("products contain only fields defined with `fields` param", async () => {
|
||||||
const response = await api.get("/store/products?fields=handle")
|
const response = await api.get("/store/products?fields=handle")
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(Object.keys(response.data.products[0])).toEqual([
|
expect(Object.keys(response.data.products[0])).toEqual(["handle", "id"])
|
||||||
"handle",
|
|
||||||
"created_at",
|
|
||||||
"id",
|
|
||||||
])
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("returns a list of products in collection", async () => {
|
it("returns a list of products in collection", async () => {
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ describe("validateAndTransformQuery", () => {
|
|||||||
|
|
||||||
expect(mockRequest.listConfig).toEqual(
|
expect(mockRequest.listConfig).toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
select: ["id", "created_at"],
|
select: ["id"],
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -406,13 +406,13 @@ describe("validateAndTransformQuery", () => {
|
|||||||
|
|
||||||
expect(mockRequest.listConfig).toEqual(
|
expect(mockRequest.listConfig).toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
select: ["store.name", "created_at", "id"],
|
select: ["store.name", "id"],
|
||||||
relations: ["store"],
|
relations: ["store"],
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
expect(mockRequest.remoteQueryConfig).toEqual(
|
expect(mockRequest.remoteQueryConfig).toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
fields: ["store.name", "created_at", "id"],
|
fields: ["store.name", "id"],
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import {
|
import {
|
||||||
getSetDifference,
|
getSetDifference,
|
||||||
|
isDefined,
|
||||||
isPresent,
|
isPresent,
|
||||||
|
MedusaError,
|
||||||
stringToSelectRelationObject,
|
stringToSelectRelationObject,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { pick } from "lodash"
|
import { pick } from "lodash"
|
||||||
import { MedusaError, isDefined } from "@medusajs/utils"
|
|
||||||
import { RequestQueryFields } from "@medusajs/types"
|
import { RequestQueryFields } from "@medusajs/types"
|
||||||
import { FindConfig, QueryConfig } from "../types/common"
|
import { FindConfig, QueryConfig } from "../types/common"
|
||||||
|
|
||||||
@@ -76,10 +77,6 @@ export function prepareListQuery<T extends RequestQueryFields, TEntity>(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Maintain backward compatibility, remove in future. the created at was only added in the list query for default order
|
|
||||||
if (queryConfig.isList) {
|
|
||||||
allFields.add("created_at")
|
|
||||||
}
|
|
||||||
allFields.add("id")
|
allFields.add("id")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user