Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion packages/runtime/src/enhancements/node/policy/policy-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1528,12 +1528,24 @@ export class PolicyUtil extends QueryUtils {
continue;
}

if (queryArgs?.omit?.[field] === true) {
if (queryArgs?.omit && typeof queryArgs.omit === 'object' && queryArgs.omit[field] === true) {
// respect `{ omit: { [field]: true } }`
delete entityData[field];
continue;
}

if (queryArgs?.select && typeof queryArgs.select === 'object' && !queryArgs.select[field]) {
// respect select
delete entityData[field];
continue;
}

if (fieldInfo.isDataModel && queryArgs?.include && typeof queryArgs.include === 'object' && !queryArgs.include[field]) {
// respect include
delete entityData[field];
continue;
}

if (hasFieldLevelPolicy) {
// 1. remove fields selected for checking field-level policies but not selected by the original query args
// 2. evaluate field-level policies and remove fields that are not readable
Expand Down
6 changes: 5 additions & 1 deletion packages/testtools/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export type SchemaLoadOptions = {
prismaLoadPath?: string;
prismaClientOptions?: object;
generateNoCompile?: boolean;
dbFile?: string;
};

const defaultOptions: SchemaLoadOptions = {
Expand Down Expand Up @@ -337,7 +338,10 @@ export function createProjectAndCompile(schema: string, options: SchemaLoadOptio
});
}

if (opt.pushDb) {
if (opt.dbFile) {
fs.cpSync(opt.dbFile, path.join(projectDir, 'prisma/dev.db'));
}
else if (opt.pushDb) {
run('npx prisma db push --skip-generate --accept-data-loss');
}

Expand Down
Binary file added tests/regression/tests/issue-2283/dev.db
Binary file not shown.
Loading
Loading