Documentation

TypeDB.TypeQL

TypeQL text #

typeql!"…" builds a Query from TypeQL text. Each {e} is rendered by ToTypeQL, which turns a Lean value into a TypeQL value literal: strings are quoted and escaped, so user data can never change a query's structure. Raw is the only way to splice text verbatim.

The query's transaction mode is inferred from the literal parts: define, undefine or redefine need a schema transaction, insert, delete, update or put a write transaction, anything else a read transaction. TypeQL braces must be escaped as \{ and \} because Lean uses {…} for interpolation.

inductive TypeDB.TxMode :

The kind of a transaction, ordered by what it may do: read ≤ write ≤ schema.

Instances For
    @[instance_reducible]
    Equations
    @[instance_reducible]
    Equations
    @[instance_reducible]
    Equations
    @[instance_reducible]
    Equations
    @[instance_reducible]
    Equations
    @[instance_reducible]
    Equations

    The driver's TransactionType.

    Equations
    Instances For
      class TypeDB.TxMode.Allows (cur need : TxMode) :

      Allows cur need: a transaction of mode cur may run an operation that needs need. Resolved at compile time; a missing instance means the operation needs a stronger transaction.

      • le : need ≤ cur
      Instances
        structure TypeDB.Query (need : TxMode) :

        TypeQL text and the weakest transaction mode that may run it.

        Instances For
          @[instance_reducible]
          Equations
          @[instance_reducible]
          Equations
          def TypeDB.Query.raw (need : TxMode) (text : String) :
          Query need

          A query from text the caller vouches for, with an explicit mode.

          Equations
          Instances For
            def TypeDB.Query.withMode {m : TxMode} (q : Query m) (need : TxMode) :
            Query need

            Runs the query under a different mode requirement, e.g. to require a write transaction for a read query whose mode the literal could not reveal.

            Equations
            Instances For
              def TypeDB.Query.append {m n : TxMode} (q₁ : Query m) (q₂ : Query n) :
              Query (max m n)

              Pipes two queries: q₁ ++ q₂ runs q₂'s stages after q₁'s, needing the stronger mode.

              Equations
              Instances For
                structure TypeDB.Raw :

                Text spliced into a query verbatim, such as a type label or a query fragment.

                Instances For
                  @[instance_reducible]
                  Equations
                  class TypeDB.ToTypeQL (α : Type) :

                  Renders a Lean value as a TypeQL value literal.

                  Instances

                    Quotes and escapes a string as a TypeQL string literal.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For

                      Civil date (year, month, day) of a day count since 1970-01-01 (Hinnant's algorithm).

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          def TypeDB.TypeQL.datetimeText (seconds : Int) (nanos : Nat) :

                          YYYY-MM-DDTHH:MM:SS[.fffffffff] for UTC seconds and nanoseconds since the epoch.

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For

                            ±HH:MM for an offset in seconds.

                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For

                              The exact decimal expansion of a finite double, or none for NaN and infinities. Every double is m · 2^e, whose decimal expansion is finite, so the literal parses back to exactly the same double.

                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                @[instance_reducible]
                                Equations
                                @[instance_reducible]
                                Equations
                                @[instance_reducible]
                                Equations
                                @[instance_reducible]
                                Equations
                                @[instance_reducible]
                                Equations
                                @[instance_reducible]
                                Equations
                                @[instance_reducible]
                                Equations
                                @[instance_reducible]
                                Equations
                                @[instance_reducible]

                                Doubles render exactly. NaN and infinities have no TypeQL literal and render as NaN or inf, which the server rejects.

                                Equations
                                @[instance_reducible]
                                Equations
                                @[instance_reducible]
                                Equations
                                @[instance_reducible]
                                Equations
                                • One or more equations did not get rendered due to their size.
                                @[instance_reducible]
                                Equations
                                • One or more equations did not get rendered due to their size.

                                The weakest mode that can run TypeQL text, from its keywords outside string literals.

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For
                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For

                                    TypeQL text with {e} holes rendered by ToTypeQL. Its transaction mode is inferred from the literal text; see the module docs.

                                    Equations
                                    • One or more equations did not get rendered due to their size.
                                    Instances For