Skip to content

Commit

Permalink
Minor language server fixes (#1013)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ustice committed Feb 19, 2024
1 parent d7b75e9 commit 4398231
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
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}`, { node: imp });
}
});
}
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


// 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
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(`
${ 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)
_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 () => {
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

0 comments on commit 4398231

Please sign in to comment.