-
-
Notifications
You must be signed in to change notification settings - Fork 113
chore: merge from dev #1017
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: merge from dev #1017
Changes from all commits
fa0dafb
da33881
a4d3f15
d530367
541cd97
43eb615
613ac8d
ad18291
b4579c7
b2e1635
0704f9d
d7b75e9
4398231
9384a86
9cb91f3
10cb00a
da53753
16df179
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ dist | |
.npmcache | ||
coverage | ||
.build | ||
.test |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
# Changelog | ||
|
||
## [Unreleased] | ||
### Added | ||
- Added support to complex usage of `@@index` attribute like `@@index([content(ops: raw("gin_trgm_ops"))], type: Gin)`. | ||
### Fixed | ||
- Fixed several ZModel validation issues related to model inheritance. | ||
|
||
## 1.7.0 | ||
### Added | ||
- Auto-completion is now supported inside attributes. |
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -52,8 +52,9 @@ export default class SchemaValidator implements AstValidator<Model> { | |||||||||||||||||
private validateImports(model: Model, accept: ValidationAcceptor) { | ||||||||||||||||||
model.imports.forEach((imp) => { | ||||||||||||||||||
const importedModel = resolveImport(this.documents, imp); | ||||||||||||||||||
const importPath = imp.path.endsWith('.zmodel') ? imp.path : `${imp.path}.zmodel`; | ||||||||||||||||||
if (!importedModel) { | ||||||||||||||||||
accept('error', `Cannot find model file ${imp.path}.zmodel`, { node: imp }); | ||||||||||||||||||
accept('error', `Cannot find model file ${importPath}`, { node: imp }); | ||||||||||||||||||
Comment on lines
+55
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The update to the + // Ensure the import path ends with '.zmodel' for consistent path resolution
const importPath = imp.path.endsWith('.zmodel') ? imp.path : `${imp.path}.zmodel`; Committable suggestion
Suggested change
|
||||||||||||||||||
} | ||||||||||||||||||
}); | ||||||||||||||||||
} | ||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,7 @@ import { upperCaseFirst } from 'upper-case-first'; | |
import { name } from '.'; | ||
import { getStringLiteral } from '../../language-server/validator/utils'; | ||
import telemetry from '../../telemetry'; | ||
import { execSync } from '../../utils/exec-utils'; | ||
import { execPackage } from '../../utils/exec-utils'; | ||
import { findPackageJson } from '../../utils/pkg-utils'; | ||
import { | ||
AttributeArgValue, | ||
|
@@ -142,7 +142,7 @@ export class PrismaSchemaGenerator { | |
if (options.format === true) { | ||
try { | ||
// run 'prisma format' | ||
await execSync(`npx prisma format --schema ${outFile}`, { stdio: 'ignore' }); | ||
await execPackage(`prisma format --schema ${outFile}`, { stdio: 'ignore' }); | ||
} catch { | ||
warnings.push(`Failed to format Prisma schema file`); | ||
} | ||
|
@@ -151,18 +151,18 @@ export class PrismaSchemaGenerator { | |
const generateClient = options.generateClient !== false; | ||
|
||
if (generateClient) { | ||
let generateCmd = `npx prisma generate --schema "${outFile}"`; | ||
let generateCmd = `prisma generate --schema "${outFile}"`; | ||
if (typeof options.generateArgs === 'string') { | ||
generateCmd += ` ${options.generateArgs}`; | ||
} | ||
try { | ||
// run 'prisma generate' | ||
await execSync(generateCmd, { stdio: 'ignore' }); | ||
await execPackage(generateCmd, { stdio: 'ignore' }); | ||
} catch { | ||
await this.trackPrismaSchemaError(outFile); | ||
try { | ||
// run 'prisma generate' again with output to the console | ||
await execSync(generateCmd); | ||
await execPackage(generateCmd); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Attempting to run |
||
} catch { | ||
// noop | ||
} | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -8,3 +8,11 @@ export function execSync(cmd: string, options?: Omit<ExecSyncOptions, 'env'> & { | |||||||||||||||||||||||||||||||
const mergedEnv = env ? { ...process.env, ...env } : undefined; | ||||||||||||||||||||||||||||||||
_exec(cmd, { encoding: 'utf-8', stdio: options?.stdio ?? 'inherit', env: mergedEnv, ...restOptions }); | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||
* Utility for running package commands through npx/bunx | ||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||
export function execPackage(cmd: string, options?: Omit<ExecSyncOptions, 'env'> & { env?: Record<string, string> }): void { | ||||||||||||||||||||||||||||||||
const packageManager = process?.versions?.bun ? 'bunx' : 'npx'; | ||||||||||||||||||||||||||||||||
execSync(`${packageManager} ${cmd}`, options) | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
Comment on lines
+12
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The addition of the + // Choose 'bunx' if 'bun' is present in the environment, otherwise default to 'npx'
const packageManager = process?.versions?.bun ? 'bunx' : 'npx'; Committable suggestion
Suggested change
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -226,6 +226,25 @@ describe('Attribute tests', () => { | |
} | ||
`); | ||
|
||
await loadModel(` | ||
${ prelude } | ||
model A { | ||
id String @id | ||
x String | ||
y String | ||
z String | ||
@@fulltext([x, y, z]) | ||
} | ||
|
||
model B { | ||
id String @id | ||
x String | ||
y String | ||
z String | ||
@@fulltext([x, y, z], map: "n") | ||
} | ||
`); | ||
Comment on lines
+229
to
+246
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The addition of models Would you like me to help generate specific test cases for validating the |
||
|
||
await loadModel(` | ||
${prelude} | ||
model A { | ||
|
@@ -352,6 +371,7 @@ describe('Attribute tests', () => { | |
_longBlob Bytes @db.LongBlob | ||
_binary Bytes @db.Binary | ||
_varBinary Bytes @db.VarBinary | ||
_varBinarySized Bytes @db.VarBinary(100) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The introduction of the Consider validating or documenting the choice of size for the |
||
_tinyBlob Bytes @db.TinyBlob | ||
_blob Bytes @db.Blob | ||
_mediumBlob Bytes @db.MediumBlob | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The updates to the
repl.ts
file, including the environment check before initializing the REPL session and moving theprettyRepl
import inside therepl
function, are thoughtful improvements. These changes enhance the CLI's usability and performance by ensuring compatibility and optimizing the import strategy. Consider adding comments explaining the environment check's purpose and the rationale behind moving theprettyRepl
import for future maintainers.Also applies to: 18-18
Committable suggestion