Light
Dark
System

EdgeDB v2 (Sagittarius)

EdgeDB 2.0 was released on July 28th, 2022. Read the announcement blog post here.

We would like to thank our community for reporting issues and contributing fixes. You are awesome! ❤️

To play with the new features, install the CLI and initialize a new project. For an interesting schema with test data, check out the MCU Sandbox repo.

Copy
$ 
edgedb project init

Local instances

To upgrade a local project, run the following command inside the project directory.

Copy
$ 
edgedb project upgrade --to-latest

Alternatively, specify an instance name if you aren’t using a project.

Copy
$ 
edgedb project upgrade --to-latest -I my_instance

Hosted instances

To upgrade a remote (hosted) instance, we recommend the following dump-and-restore process.

1. Spin up an empty 2.0 instance by following one of our deployment guides. These guides have been updated to 2.0. Keep the DSN of the newly created instance handy.

  1. Take your application offline, then dump your v1.x database with the CLI

    Copy
    $ 
    edgedb dump --dsn <old dsn> --all my_database.dump/

    This will dump the schema and contents of your current database to a file on your local disk called my_database.dump. The file name isn’t important.

  2. Restore the empty v2.x instance from the dump

    Copy
    $ 
    edgedb restore --all my_database.dump/ --dsn <new dsn>

    Once the restore is complete, update your application to connect to the new instance.

This process will involve some downtime, specifically during steps 2 and 3. We are working on an in-place upgrade workflow that will reduce the amount of downtime involved and avoid the need to spin up a new instance. We’ll publish that soon; join the Discord for updates. Though for most applications the dump-and-restore workflow will be simpler and less error-prone.

We’ve released new versions of our JavaScript and Python client libraries that support all 2.0 features and implement the updated protocol. These versions are backwards compatible with v1.x instances, so we encourage all users to upgrade.

TypeScript/JS

edgedb@0.21.0

Python

edgedb@0.24.0

Golang

edgedb@0.12.0

Rust

edgedb-tokio@0.3.0

.NET (community-maintained)

EdgeDB.Net.Driver@0.3.0

Elixir (community-maintained)

edgedb@0.4.0

All v2 instances ship with a built-in rich admin GUI. Access it by running edgedb ui inside any EdgeDB project, or specify a local instance name with edgedb ui -I my_inst. The command opens the instance’s admin UI using the default system browser.

The current iteration of the GUI has

  • a data browser and editor

  • a REPL for writing and executing EdgeQL queries

  • a schema introspection tool with text-based and graphical visualizations of the instance’s current schema

The new GROUP expression can be used to partition and aggregate data. The output of GROUP are free objects representing each group, including the grouping, the grouping key, and the set of elements.

Copy
db> 
group Movie { title } by .release_year;
{
  {
    key: {release_year: 2017},
    grouping: {'release_year'},
    elements: {
      default::Movie {title: 'Guardians of the Galaxy Vol. 2'},
      default::Movie {title: 'Spider-Man: Homecoming'},
      default::Movie {title: 'Thor: Ragnarok'},
    },
  },
  {
    key: {release_year: 2013},
    grouping: {'release_year'},
    elements: {
      default::Movie {title: 'Iron Man 3'},
      default::Movie {title: 'Thor: The Dark World'},
    },
  },
  ...
}

Browse the docs for more details and examples, or refer to the original RFC 1009.

Your schema can now contain global variables. These are contextual variables that are provided by the client and can be referenced in your queries and schema.

Copy
global current_user -> uuid;
Copy
select User filter .id = global current_user;

Client libraries have been updated to provide method for attaching global variables to a Client instance; these values are sent along with all queries originating from that Client.

TypeScript
Python
Go
Copy
import {createClient} from 'edgedb';

const client = createClient().withGlobals({
  current_user: '2141a5b4-5634-4ccc-b835-437863534c51',
});

await client.query(`select global current_user;`);
Copy
from edgedb import create_client

client = create_client().with_globals({
    'current_user': '580cc652-8ab8-4a20-8db9-4c79a4b1fd81'
})

result = client.query("""
    select global current_user;
""")
Copy
package main

import (
  "context"
  "fmt"
  "log"

  "github.com/edgedb/edgedb-go"
)

func main() {
  ctx := context.Background()
  client, err := edgedb.CreateClient(ctx, edgedb.Options{})
  if err != nil {
    log.Fatal(err)
  }
  defer client.Close()

  id, err := edgedb.ParseUUID("2141a5b4-5634-4ccc-b835-437863534c51")
  if err != nil {
    log.Fatal(err)
  }

  var result edgedb.UUID
  err = client.
    WithGlobals(map[string]interface{}{"current_user": id}).
    QuerySingle(ctx, "SELECT global current_user;", &result)
  if err != nil {
    log.Fatal(err)
  }

  fmt.Println(result)
}

Globals are primarily intended as an enabling mechanism for object-level security.

Object types can now be augmented with object-level access policies. When combined with global variables, access policies can be used to push authorization logic into the database.

Copy
global current_user -> uuid;

type User {
  required property email -> str { constraint exclusive; };
}

type BlogPost {
  required property title -> str;
  link author -> User;
  access policy own_posts allow all using (
    .author.id ?= global current_user
  )
}

Refer to the docs or RFC 1011 for full details.

EdgeDB now supports range types representing intervals of values.

Copy
db> 
select range(1, 10);
{range(1, 10, inc_lower := true, inc_upper := false)}
Copy
db> 
select range_unpack(range(1, 10))
{1, 2, 3, 4, 5, 6, 7, 8, 9}

This release also introduces a new datatype cal::date_duration to represent a span of months/days. It is nearly equivalent to the existing cal::relative_duration but cannot represent sub-day durations.

This type is primarily intended to simplify cal::local_date logic.

db> select <cal::local_date>'2022-06-25' +
...   <cal::date_duration>'5 days';
{<cal::local_date>'2022-06-30'}
db> select <cal::local_date>'2022-06-30' -
...   <cal::local_date>'2022-06-25';
{<cal::date_duration>'P5D'}

Add deletion cascade functionality with on source delete.

Copy
type BlogPost {
  property title -> str;
}

type Person {
  multi link posts -> BlogPost {
    on source delete delete target;
  }
}

Under this policy, deleting a User will unconditionally delete its posts as well.

To avoid deleting a Post that is linked to by other schema entities, append if orphan.

Copy
type Person {
  multi link posts -> BlogPost {
    on source delete delete target;
    on source delete delete target if orphan;
  }
}
  • Support socket activation to reduce memory footprint on developer machines (#3899).

  • Introduce edgedb+http, a which tunnels the binary protocol over HTTP using JWT for authentication (#3979).

  • Support using JWT to authenticate to local instances (#3991).

  • Generate unique id fields for each free shape object, and don’t use an actual in-database object to represent it, and make multiplicity inference understand free shapes better (#3631, #3633, #3634).

  • Fail if local Postgres cluster fails to start.

  • Add cfg::memory to base types descriptor IDs table (#3882).

  • Fix a cross-type exclusive constraint bug that could allow exclusive constraints to be violated in some complex type hierarchies (#3887).

  • Fix issue where server might attempt to acquire one more connection than it is configured to permit (#3901).

  • Fix use of assert_exists on properties that are being directly output (#3911).

  • Fix a scope leakage that could cause a link referenced inside a computable to improperly correlate with something outside the computable (#3912).

  • Fix a number of issues with the floordiv (//) and modulus (%) operators where we could return incorrect values or produce spurious errors, especially on very large values (#3909).

  • Allow adding annotations to abstract annotation definitions (#3929).

  • Expose body and language fields on schema::Function (#3944).

  • Make indexes extend from schema::InheritingObject (#3942).

  • Fix some mis-compilations of nested shapes inside calls to functions like assert_single (#3927).

  • Fix SET TYPE on properties with default values (#3954).

  • Fix describe/populate/describe sequence (#3959).

  • Upgrade many casts and functions from “Stable” to “Immutable” (#3975).

  • Fix link properties in type filtered shape links (#3987).

  • Allow DML statements in free shapes (#4002).

  • Allow customizing assertion messages in assert_exists and friends (#4019).

  • A new version of the protocol—version 1.0—has been introduced. It eliminates all server state associated with connections that do not use transactions.

  • Support passing parameters to and returning values from multi-statement scripts.

  • Fix global defaults with nontrivial computation (#4182)

  • Fix migration that removes policy using clause (#4183)

  • Support ELSE-less UNLESS CONFLICT on explicit id INSERT (#4185)

  • Don’t create constraints on derived views when adding a pointer to a type (#4187)

  • Fix a bunch of missing source contexts in declarative (#4188)

  • Fix an ISE when a computed link is directly a property reference (#4193)

  • Fix an ISE when using an empty shape in some contexts (#4194)

  • Fix a number of error messages involving collection types in schemas (#4195)

  • Avoid doing semi-joins after a sequence of single links (#4196)

  • Make range() properly strict in its non-optional arguments (#4207)

  • Allow multiple FDs per socket in activation (#4189)

  • Add SCRAM authentication over HTTP (#4197)

  • Always arm auto-shutdown timer when it’s greater than zero (#4214)

  • Fix json -> array<json> cast of ‘[]’ (#4217)

  • Support UNLESS CONFLICT ON for pointers with DML in them (#4357)

  • Fix cardinality in CommandDataDescription (#4347)

  • Prevent access rule hidden ids from leaking when accessed directly (#4339)

  • Better messages for required links hidden by policies (#4338)

  • Fix access policies on DELETE of a UNION type (#4337)

  • Strip out all views from DML subjects when computing what tables to use (#4336, #4333)

  • Fix interaction between access policies and omitted fields in insert (#4332, #4219)

  • Fix a tracer issue with reverse links and IS (#4331)

  • Don’t include union types in link triggers (#4329, #4320)

    If you encounter this issue, after upgrading to a version with this patch, it can be fixed by doing a dump/restore or by adding a new link to the affected type.

  • Require ON for constraints on objects (#4324, #4268)

  • Fix interaction between DETACHED and aliases/globals (#4321, #4258)

  • Disable access policy rewrite when compiling constraints (#4248, #4245)

  • Expose --admin-ui as an environment variable and document it (#4255)

  • Prevent HttpProtocol.close from crashing on closed client connection (#4238)

  • Fix permitted JSON null in nested array cast (#4221)

  • Fix range_unpack boundary bug.

    The range_unpack function was incorrectly excluding values close to boundary, especially when the boundary was not itself inclusive. (#4282)

  • UI: Allow selection of read-only properties in data editor (edgedb/edgedb-ui/#65)

  • UI: Hide subtype columns in data editor by default; add a toggle to show them. (edgedb/edgedb-ui/#43)

  • UI: Add “create example database” to the database selection screen. (edgedb/edgedb-ui/#61)

  • UI: Fix navigation from being reset on switching the UI panes. (edgedb/edgedb-ui/#61)

  • UI: Fix rendering of range types. (edgedb/edgedb-ui/#61)

  • UI: Fix the data editor UI to render types that have some properties or links masked by an access policy. (edgedb/edgedb-ui/#61)

  • UI: Implement login page for remote instances. (edgedb/edgedb-ui/#40)

  • Clarify error message when UI is not enabled (#4256)

  • Fix an issue with inherited computeds (#4371)

  • Fix bug in diamond pattern constraint inheritance (#4379)

  • When finding common parent for arrays, never use expr alias arrays (#4080)

  • Properly quote numeric names when in codegen (#4344)

  • Fix computed global scoping behavior (#4388)

  • Fix DDL performance issues on databases with lots of data (#4401)

  • Fix potentially missed constraints on DML (#4410)

  • Fix slicing with an empty set (#4404)

  • Fix slicing array of tuples (#4391)

  • Don’t apply access policies when compiling indexes (#4420)

  • Fix slicing of tuple arrays with null inputs (#4421)

  • Propagate database creation and deletion events to adjacent servers (#4415)

  • Fix database initialization on hosted environments like Heroku. (#4432)

  • Prevent spurious errors when using backlinks on types that have properties with the same name but different types (#4443)

  • Fix some spurious errors when removing a link from the schema. (#4451)

  • For query_single, only check that the last query in a script is single. (#4453)

  • Catch when POPULATE MIGRATION generates incorrect DDL. This should prevent bugs where the schema can get into wedged states. (#4484)

  • workflows: Publish multiarch Docker images (#4486)

  • Make unused param insertion in the sql compiler more reliable (#4497)

  • Properly propagate creation and deletion of extensions

  • Fix potential exclusive constraint violations when doing an UPDATE on a union (#4507)

  • Don’t lose type from inheritance views when rebasing (#4509)

  • Make object type descriptor ids be derived from type name (#4503)

  • Check for invalid arrays arguments at the protocol level (#4511)

  • Fix SET REQUIRED on newly created properties with alias subtypes (#4513)

  • Make newly created link properties get added to the relevant alias types (#4512)

  • Fix handling of link properties named id (#4514)

  • Disallow queries using conflict machinery on a link property. This prevents certain potential exclusive constraint violations that were not handled correctly. (#4515)

  • Fix performing multiple deletions at once in the UI (#4523)

  • Fix casting empty sets to built in enum types (#4532)

  • Produce better error messages when using enum incorrectly (#4527)

  • Make '\b' produce the correct value in string and bytes literals (#4535)

  • Properly infer cardinality of empty array as ONE (#4533)

  • Fix several issues that manifest when using GROUP BY (#4549, #4439)

  • Fix migration scripts when combined with access policies (#4553)

  • Fix failure when a ALTER ... EXTENDING doesn’t change the set of ancestors (#4554)

  • Fix UNLESS CONFLICT ON for a not-inserted property (#4556)

  • Fix access policies that use shapes internally (#4555)

  • Allow overloading __type__ with a computed in shapes (#4557)

Starting with EdgeDB 3.0, access policy restrictions will not be applied while evaluating other access policy expressions (#4574).

It is possible (and recommended) to enable this future behavior in EdgeDB 2.6 by adding the following to the schema: using future nonrecursive_access_policies;

For more details, see the docs.

To enable opting in to this behavior, 2.6 adds a general mechanism to opt into future behavior changes (#4574, #4606).

  • Fix passing zero dimensional array as arguments. This was a regression introduced in 2.4, and affected passing empty arrays from the the Rust bindings. (#4511)

  • Require that constraint expressions be immutable (#4593)

  • Only permit valid UUID-generation functions to be made the default value for id (#4616)

  • UI: New mechanism for copying data in REPL and in Data Editor. Hover over a data line and click the context “COPY” button.

  • UI: “Disable Access Policies” and “Persist Query” options in REPL remember their state between page refreshes.

  • UI: Basic autocomplete now works for INSERT, UPDATE, and DELETE queries.

  • Improve error messages when compiling pointer default (#4624)

  • Fix using WITH-bound DML from an UPDATE in an ELSE clause (#4641)

  • Allow WITH MODULE in ddl in CREATE MIGRATION (#4668)

  • Fix some broken casts from object types to JSON (#4663)

  • Fix putting a statement as the body of an access policy (#4667)

  • Loosen the rules on when we produce a “would change the interpretation” error. It is not only produced when a link is being used, not a property. (#4643)

  • Fix certain errors involving default values in access policies (#4679)

  • Avoid ISE when pickling DynamicRangeVar (#4681)

  • Fix max_ex_value constraint. (#4671)

  • Fix SET GLOBAL capabilities to no longer break in the CLI. (#4688)

  • Fix links to schema::ObjectType breaking DROP TYPE. If you have a link in your schema to schema::ObjectType or one of its ancestors and you encounter internal server errors when trying to drop a type, it should be possible to repair your database by creating and then deleting a new link to schema::ObjectType. (#4670)

  • Don’t insert unnecessary assert_exists calls on required links inside access policies bodies in some cases. (#4695)

Light
Dark
System