Crate parser_database

source ·
Expand description

See the docs on ParserDatabase.

Scope

The ParserDatabase is tasked with gathering information about the schema. It is connector agnostic: it gathers information and performs generic validations, leaving connector-specific validations to later phases in datamodel core.

Terminology

Names:

  • name: the item name in the schema for datasources, generators, models, model fields, composite types, composite type fields, enums and enum variants. The name: argument for unique constraints, primary keys and relations.
  • mapped name: the name inside an @map() or @@map() attribute of a model, field, enum or enum value. This is used to determine what the name of the Prisma schema item is in the database.
  • database name: the name in the database, once both the name of the item and the mapped name have been taken into account. The logic is always the same: if a mapped name is defined, then the database name is the mapped name, otherwise it is the name of the item.
  • constraint name: indexes, primary keys and defaults can have a constraint name. It can be defined with a map: argument or be a default, generated name if the map: argument is not provided. These usually require a datamodel connector to be defined.

Modules

  • The AST data structure. It aims to faithfully represent the syntax of a Prisma Schema, with source span information.
  • Coerce expressions to a specific type, emitting a validation error if the coercion fails. See the coerce_opt module if you do not want to emit validation errors.
  • Fallible coercions of PSL expressions to more specific types.
  • Convenient access to a datamodel as understood by ParserDatabase.

Structs

  • Defines a path to a field that is not directly in the model.
  • Identifier for a single implicit many-to-many relation in a Prisma schema.
  • ParserDatabase is a container for a Schema AST, together with information gathered during schema validation. Each validation step enriches the database with information that can be used to work with the schema, without changing the AST. Instantiating with ParserDatabase::new() will perform a number of validations and make sure the schema makes sense, but it cannot fail. In case the schema is invalid, diagnostics will be created and the resolved information will be incomplete.
  • An opaque identifier for a model relation field in a schema.
  • Identifier for a single relation in a Prisma schema.
  • An opaque identifier for a model scalar field in a schema.
  • A Prisma schema document.

Enums

  • A type of index as defined by the type: ... argument on an index attribute.
  • The different types of indexes supported in the Prisma Schema Language.
  • Defines operators captured by the index. Used with PostgreSQL GiST/SP-GiST/GIN/BRIN indices.
  • An action describing the way referential integrity is managed in the system.
  • The type of a scalar field, parsed and categorized.
  • Prisma’s builtin scalar types.
  • The sort order of an index.

Functions

  • Coerce an expression to an array. The coercion function is used to coerce the array elements.
  • Is this a valid type name for the Prisma Client API?