Skip to content
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

Minor language server fixes #1013

Merged
merged 3 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -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}.zmodel`, { node: imp });
ymc9 marked this conversation as resolved.
Show resolved Hide resolved
ymc9 marked this conversation as resolved.
Show resolved Hide resolved
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions packages/schema/src/res/stdlib.zmodel
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ attribute @updatedAt() @@@targetField([DateTimeField]) @@@prisma
/**
* Add full text index (MySQL only).
*/
attribute @@fulltext(_ fields: FieldReference[]) @@@prisma
attribute @@fulltext(_ fields: FieldReference[], map: String?) @@@prisma
ymc9 marked this conversation as resolved.
Show resolved Hide resolved


// String type modifiers
Expand Down Expand Up @@ -479,7 +479,7 @@ attribute @db.Bytes() @@@targetField([BytesField]) @@@prisma
attribute @db.ByteA() @@@targetField([BytesField]) @@@prisma
attribute @db.LongBlob() @@@targetField([BytesField]) @@@prisma
attribute @db.Binary() @@@targetField([BytesField]) @@@prisma
attribute @db.VarBinary() @@@targetField([BytesField]) @@@prisma
attribute @db.VarBinary(_ x: Int?) @@@targetField([BytesField]) @@@prisma
ymc9 marked this conversation as resolved.
Show resolved Hide resolved
attribute @db.TinyBlob() @@@targetField([BytesField]) @@@prisma
attribute @db.Blob() @@@targetField([BytesField]) @@@prisma
attribute @db.MediumBlob() @@@targetField([BytesField]) @@@prisma
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,25 @@ describe('Attribute tests', () => {
}
`);

await loadModel(`
ymc9 marked this conversation as resolved.
Show resolved Hide resolved
${ 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")
}
`);

await loadModel(`
${prelude}
model A {
Expand Down Expand Up @@ -352,6 +371,7 @@ describe('Attribute tests', () => {
_longBlob Bytes @db.LongBlob
_binary Bytes @db.Binary
_varBinary Bytes @db.VarBinary
_varBinarySized Bytes @db.VarBinary(100)
ymc9 marked this conversation as resolved.
Show resolved Hide resolved
_tinyBlob Bytes @db.TinyBlob
_blob Bytes @db.Blob
_mediumBlob Bytes @db.MediumBlob
Expand Down
14 changes: 14 additions & 0 deletions packages/schema/tests/schema/validation/schema-validation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,20 @@ describe('Toplevel Schema Validation Tests', () => {
).toContain('Cannot find model file models/abc.zmodel');
});

it('not existing import with extension', async () => {
ymc9 marked this conversation as resolved.
Show resolved Hide resolved
expect(
await loadModelWithError(`
import 'models/abc.zmodel'
datasource db1 {
provider = 'postgresql'
url = env('DATABASE_URL')
}

model X {id String @id }
`)
).toContain('Cannot find model file models/abc.zmodel');
})

it('multiple auth models', async () => {
expect(
await loadModelWithError(`
Expand Down
Loading