diff --git a/packages/schema/src/language-server/validator/schema-validator.ts b/packages/schema/src/language-server/validator/schema-validator.ts index b80bf890d..6f868c614 100644 --- a/packages/schema/src/language-server/validator/schema-validator.ts +++ b/packages/schema/src/language-server/validator/schema-validator.ts @@ -52,8 +52,9 @@ export default class SchemaValidator implements AstValidator { 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 }); } }); } diff --git a/packages/schema/src/res/stdlib.zmodel b/packages/schema/src/res/stdlib.zmodel index a3bee6b2e..145ffed60 100644 --- a/packages/schema/src/res/stdlib.zmodel +++ b/packages/schema/src/res/stdlib.zmodel @@ -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 @@ -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 diff --git a/packages/schema/tests/schema/validation/attribute-validation.test.ts b/packages/schema/tests/schema/validation/attribute-validation.test.ts index b86637b58..8eb674b2f 100644 --- a/packages/schema/tests/schema/validation/attribute-validation.test.ts +++ b/packages/schema/tests/schema/validation/attribute-validation.test.ts @@ -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 { @@ -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 diff --git a/packages/schema/tests/schema/validation/schema-validation.test.ts b/packages/schema/tests/schema/validation/schema-validation.test.ts index 5f1cc6254..ca0efa697 100644 --- a/packages/schema/tests/schema/validation/schema-validation.test.ts +++ b/packages/schema/tests/schema/validation/schema-validation.test.ts @@ -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(`