-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add foreign keys to the generated query types output
- Loading branch information
1 parent
1e7c072
commit c78097b
Showing
4 changed files
with
40 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
packages/core/utils/src/dml/helpers/entity-builder/relationship-helpers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { RelationshipMetadata } from "@medusajs/types" | ||
import { camelToSnakeCase } from "../../../common/camel-to-snake-case" | ||
|
||
/** | ||
* Returns the foreign key name for a relationship | ||
*/ | ||
export function getForeignKey(relationship: RelationshipMetadata) { | ||
return ( | ||
relationship.options.foreignKeyName ?? | ||
camelToSnakeCase(`${relationship.name}Id`) | ||
) | ||
} |