question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add `module` block to SDL

See original GitHub issue

The current version of SDL and migrations does not allow expressing the migration of interdependent modules because a single SDL blob is only supposed to reference one module. The solution to this is to force SDL to express the entire user-schema in the context of migration. This means that a single SDL block must denote unambiguously which modules the various entities belong to. There are two mechanisms proposed for that:

  1. Fully-qualified names for all entities (except ones belonging to std, since that’s always built-in in all contexts).
  2. A special module <name> { ... } block. All inner SDL inside this block is understood to have the default module <name>. It is possible to have multiple module blocks with the same name in a single SDL document.

The total list of modules in the schema is inferred from module block names and from fully-qualified names.

Example of SDL using module blocks:

module default {
   # the default module here is "default"
   type Foo {
      # the module "std" is also part of the default name 
      # resolution as usual
      property name -> str;
      link bar -> other_mod::Bar;
   }
}

module other_mod {
   # the default module here is "other_mod"
   type Bar {
      link bar -> Bar;
      link foo -> default::Foo;
   }
}

And the same schema expressed using only fully-qualified names SDL:

# only the "std" module can be omitted here, all other 
# names have to be fully-qualified, even "defaut"
type default::Foo {
   property name -> str;
   link bar -> other_mod::Bar;
}

type other_mod::Bar {
   link bar -> other_mod::Bar;
   link foo -> default::Foo;
}

The following schemas are also equivalent:

# Multiple module blocks with the same name
module default {
   type Foo;
}

module other_mod {
   type Bar;
}

module default {
   type Foo2;
}
# Each module block has a unique name
module default {
   type Foo;
   type Foo2;
}

module other_mod {
   type Bar;
}
# Mix of fully-qualified names and module blocks
type default::Foo;

module other_mod {
   type Bar;
}

module default {
   type Foo2;
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:19 (19 by maintainers)

github_iconTop GitHub Comments

1reaction
vpetrovykhcommented, Nov 29, 2019

The options 1 and 2 are mutually exclusive, meaning:

  • A fully qualified name (so a name of the form <module>::<shortname>) can only be used in a declaration that is not nested in any module block. It is also a requirement to use fully-qualified name in this case.
  • It is illegal to use fully-qualified name in a declaration inside a module block, only short names are allowed.

This is legal:

type default::User;
module other {
   type User;
}

This is not legal:

# this name is not fully-qualified
type User {
}
module other {
  type User { }
}
0reactions
vpetrovykhcommented, Dec 5, 2019

The new SDL syntax has been implemented.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Modules — SDL | EdgeDB Docs
The module block declaration defines a new module similar to the create module command, but it also allows putting the module content as...
Read more >
Exercise: Convert your data map to SDL - Apollo GraphQL
Goal: Convert the data map you created earlier into SDL. (Don't worry about mutations for now.) Create types Track , Author , and...
Read more >
SDL2/MigrationGuide - SDL Wiki
Now you can create an SDL_Surface that is always in RAM instead of using the one you would have gotten from SDL_SetVideoMode() ,...
Read more >
Understanding C++ Modules: Part 3: Linkage and Fragments
In the above example, add , sub , and get_value all have external linkage, and counter has module linkage. There is no way...
Read more >
SDL library in C/C++ with examples - GeeksforGeeks
Run command sudo apt-get install libsdl2-2.0-0 libsdl2-dbg libsdl2-dev libsdl2-image-2.0-0 libsdl2-image-dbg libsdl2-image-dev on your terminal.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found