🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@prisma-next/sql-contract-psl

Package Overview
Dependencies
Maintainers
4
Versions
541
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prisma-next/sql-contract-psl - npm Package Compare versions

Comparing version
0.15.0-dev.22
to
0.15.0-dev.23
dist/interpreter-OEmv4WKO.mjs

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

+1
-1

@@ -1,2 +0,2 @@

import { t as interpretPslDocumentToSqlContract } from "./interpreter-BYP3e_Mq.mjs";
import { t as interpretPslDocumentToSqlContract } from "./interpreter-OEmv4WKO.mjs";
export { interpretPslDocumentToSqlContract };

@@ -1,2 +0,2 @@

import { t as interpretPslDocumentToSqlContract } from "./interpreter-BYP3e_Mq.mjs";
import { t as interpretPslDocumentToSqlContract } from "./interpreter-OEmv4WKO.mjs";
import { buildSymbolTable, rangeToPslSpan } from "@prisma-next/psl-parser";

@@ -3,0 +3,0 @@ import { ifDefined } from "@prisma-next/utils/defined";

{
"name": "@prisma-next/sql-contract-psl",
"version": "0.15.0-dev.22",
"version": "0.15.0-dev.23",
"license": "Apache-2.0",

@@ -9,16 +9,16 @@ "type": "module",

"dependencies": {
"@prisma-next/config": "0.15.0-dev.22",
"@prisma-next/contract": "0.15.0-dev.22",
"@prisma-next/framework-components": "0.15.0-dev.22",
"@prisma-next/psl-parser": "0.15.0-dev.22",
"@prisma-next/sql-contract": "0.15.0-dev.22",
"@prisma-next/sql-contract-ts": "0.15.0-dev.22",
"@prisma-next/utils": "0.15.0-dev.22",
"@prisma-next/config": "0.15.0-dev.23",
"@prisma-next/contract": "0.15.0-dev.23",
"@prisma-next/framework-components": "0.15.0-dev.23",
"@prisma-next/psl-parser": "0.15.0-dev.23",
"@prisma-next/sql-contract": "0.15.0-dev.23",
"@prisma-next/sql-contract-ts": "0.15.0-dev.23",
"@prisma-next/utils": "0.15.0-dev.23",
"pathe": "^2.0.3"
},
"devDependencies": {
"@prisma-next/contract-authoring": "0.15.0-dev.22",
"@prisma-next/test-utils": "0.15.0-dev.22",
"@prisma-next/tsconfig": "0.15.0-dev.22",
"@prisma-next/tsdown": "0.15.0-dev.22",
"@prisma-next/contract-authoring": "0.15.0-dev.23",
"@prisma-next/test-utils": "0.15.0-dev.23",
"@prisma-next/tsconfig": "0.15.0-dev.23",
"@prisma-next/tsdown": "0.15.0-dev.23",
"arktype": "^2.2.2",

@@ -25,0 +25,0 @@ "tsdown": "0.22.8",

@@ -441,2 +441,19 @@ import type { ContractSourceDiagnostic } from '@prisma-next/config/config-types';

/**
* A set of columns is unique when it exactly matches one of the model's unique
* column sets — its primary key or any single- or multi-column `@unique` /
* `@@unique` constraint. Set equality (not subset) is required: a singular
* back-relation means at most one child per parent, which a unique constraint
* covering exactly the FK columns guarantees.
*/
function fkColumnsAreUnique(
localColumns: readonly string[],
uniqueColumnSets: readonly (readonly string[])[],
): boolean {
const local = new Set(localColumns);
return uniqueColumnSets.some(
(columns) => columns.length === local.size && columns.every((column) => local.has(column)),
);
}
export function applyBackrelationCandidates(input: {

@@ -447,2 +464,3 @@ readonly backrelationCandidates: readonly ModelBackrelationCandidate[];

readonly modelIdColumns: ReadonlyMap<string, readonly string[]>;
readonly modelUniqueColumnSets: ReadonlyMap<string, readonly (readonly string[])[]>;
readonly modelRelations: Map<string, ModelRelationMetadata[]>;

@@ -512,2 +530,15 @@ readonly diagnostics: ContractSourceDiagnostic[];

if (!candidate.isList) {
const uniqueColumnSets = input.modelUniqueColumnSets.get(matched.declaringModelName) ?? [];
if (!fkColumnsAreUnique(matched.localColumns, uniqueColumnSets)) {
input.diagnostics.push({
code: 'PSL_NON_UNIQUE_BACKRELATION',
message: `Backrelation field "${candidate.modelName}.${candidate.field.name}" is singular, but the matching FK on "${matched.declaringModelName}" (fields ${matched.localColumns.map((column) => `"${column}"`).join(', ')}) is not unique. A singular back-relation implies at most one related row; add @unique (or @@unique([...])) to the FK fields, or make "${candidate.field.name}" a list.`,
sourceId: input.sourceId,
span: candidate.field.span,
});
continue;
}
}
relationsForModel(input.modelRelations, candidate.modelName).push({

@@ -514,0 +545,0 @@ fieldName: candidate.field.name,

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display