Skip to content

Commit

Permalink
Fix Place and Person constraints to delegated (#82)
Browse files Browse the repository at this point in the history
* Update Place.name to delegated constraint

* Update Person.name to delegated constraint

* Update Place.name constraint in Chinese translation

* Update index.md

Removed an English sentence from the translation.

Co-authored-by: Victor Petrovykh <[email protected]>
  • Loading branch information
vladpi and vpetrovykh authored Oct 28, 2022
1 parent 31de816 commit 30d81e3
Show file tree
Hide file tree
Showing 24 changed files with 62 additions and 40 deletions.
2 changes: 1 addition & 1 deletion chapter10/code.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ START MIGRATION TO {
module default {
abstract type Person {
property name -> str {
constraint exclusive;
delegated constraint exclusive;
}
multi link places_visited -> Place;
multi link lover -> Person;
Expand Down
4 changes: 2 additions & 2 deletions chapter11/code.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ START MIGRATION TO {
module default {
abstract type Person {
property name -> str {
constraint exclusive;
delegated constraint exclusive;
}
multi link places_visited -> Place;
multi link lover -> Person;
Expand Down Expand Up @@ -40,7 +40,7 @@ START MIGRATION TO {
abstract type Place {
required property name -> str {
constraint exclusive;
delegated constraint exclusive;
}
property modern_name -> str;
property important_places -> array<str>;
Expand Down
4 changes: 2 additions & 2 deletions chapter12/code.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ START MIGRATION TO {
module default {
abstract type Person {
property name -> str {
constraint exclusive;
delegated constraint exclusive;
}
multi link places_visited -> Place;
multi link lover -> Person;
Expand Down Expand Up @@ -40,7 +40,7 @@ START MIGRATION TO {
abstract type Place {
required property name -> str {
constraint exclusive;
delegated constraint exclusive;
}
property modern_name -> str;
property important_places -> array<str>;
Expand Down
4 changes: 2 additions & 2 deletions chapter13/code.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ START MIGRATION TO {
module default {
abstract type Person {
property name -> str {
constraint exclusive;
delegated constraint exclusive;
}
multi link places_visited -> Place;
multi link lover -> Person;
Expand Down Expand Up @@ -41,7 +41,7 @@ START MIGRATION TO {
abstract type Place {
required property name -> str {
constraint exclusive;
delegated constraint exclusive;
}
property modern_name -> str;
property important_places -> array<str>;
Expand Down
4 changes: 2 additions & 2 deletions chapter14/code.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ START MIGRATION TO {
module default {
abstract type Person {
property name -> str {
constraint exclusive;
delegated constraint exclusive;
}
multi link places_visited -> Place;
multi link lover -> Person;
Expand Down Expand Up @@ -41,7 +41,7 @@ START MIGRATION TO {
abstract type Place {
required property name -> str {
constraint exclusive;
delegated constraint exclusive;
}
property modern_name -> str;
property important_places -> array<str>;
Expand Down
4 changes: 2 additions & 2 deletions chapter15/code.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ START MIGRATION TO {
abstract type Person {
property name -> str {
constraint exclusive;
delegated constraint exclusive;
}
multi link places_visited -> Place;
multi link lover -> Person;
Expand Down Expand Up @@ -56,7 +56,7 @@ START MIGRATION TO {
abstract type Place extending HasCoffins {
required property name -> str {
constraint exclusive;
delegated constraint exclusive;
}
property modern_name -> str;
property important_places -> array<str>;
Expand Down
2 changes: 1 addition & 1 deletion chapter15/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ With our abstract type done, we will want to have a lot of types `extending` thi
```sdl
abstract type Place extending HasCoffins {
required property name -> str {
constraint exclusive;
delegated constraint exclusive;
};
property modern_name -> str;
property important_places -> array<str>;
Expand Down
4 changes: 2 additions & 2 deletions chapter16/code.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ START MIGRATION TO {
abstract type Person {
property name -> str {
constraint exclusive;
delegated constraint exclusive;
}
multi link places_visited -> Place;
multi link lover -> Person;
Expand Down Expand Up @@ -56,7 +56,7 @@ START MIGRATION TO {
abstract type Place extending HasCoffins {
required property name -> str {
constraint exclusive;
delegated constraint exclusive;
}
property modern_name -> str;
property important_places -> array<str>;
Expand Down
4 changes: 2 additions & 2 deletions chapter17/code.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ START MIGRATION TO {
default := 0;
}
required property name -> str {
constraint exclusive;
delegated constraint exclusive;
constraint max_len_value(30);
}
}
abstract type Person {
property name -> str {
constraint exclusive;
delegated constraint exclusive;
}
multi link places_visited -> Place;
multi link lover -> Person;
Expand Down
2 changes: 1 addition & 1 deletion chapter17/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ abstract type HasNameAndCoffins {
default := 0;
}
required property name -> str {
constraint exclusive;
delegated constraint exclusive;
constraint max_len_value(30);
}
}
Expand Down
4 changes: 2 additions & 2 deletions chapter18/code.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ START MIGRATION TO {
default := 0;
}
required property name -> str {
constraint exclusive;
delegated constraint exclusive;
constraint max_len_value(30);
}
}
abstract type Person {
property name -> str {
constraint exclusive;
delegated constraint exclusive;
}
multi link places_visited -> Place;
multi link lover -> Person;
Expand Down
4 changes: 2 additions & 2 deletions chapter19/code.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ START MIGRATION TO {
default := 0;
}
required property name -> str {
constraint exclusive;
delegated constraint exclusive;
constraint max_len_value(30);
}
}
abstract type Person {
property name -> str {
constraint exclusive;
delegated constraint exclusive;
}
multi link places_visited -> Place;
multi link lover -> Person;
Expand Down
4 changes: 2 additions & 2 deletions chapter20/code.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ START MIGRATION TO {
default := 0;
}
required property name -> str {
constraint exclusive;
delegated constraint exclusive;
constraint max_len_value(30);
}
}
abstract type Person {
property name -> str {
constraint exclusive;
delegated constraint exclusive;
}
multi link places_visited -> Place;
multi link lover -> Person;
Expand Down
4 changes: 2 additions & 2 deletions chapter20/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ abstract type HasNameAndCoffins {
default := 0;
}
required property name -> str {
constraint exclusive;
delegated constraint exclusive;
constraint max_len_value(30);
}
}
Expand All @@ -66,7 +66,7 @@ abstract type Person {
property title -> str;
property degrees -> str;
required property name -> str {
constraint exclusive
delegated constraint exclusive;
}
property age -> int16;
property conversational_name := .title ++ ' ' ++ .name IF EXISTS .title ELSE .name;
Expand Down
2 changes: 1 addition & 1 deletion chapter7/code.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ START MIGRATION TO {
module default {
abstract type Person {
required property name -> str {
constraint exclusive;
delegated constraint exclusive;
}
multi link places_visited -> Place;
link lover -> Person;
Expand Down
12 changes: 12 additions & 0 deletions chapter7/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ abstract type Person {

With that you can have up to one Jonathan Harker the `PC`, the `NPC`, the `Vampire`, and anything else that extends `Person`.

Also, the `delegated constraint` applies to `Place`, since for example `Country` can have the same name as `City`. So let's update `name` property for the `Place` type:

```sdl
abstract type Place {
required property name -> str {
delegated constraint exclusive;
};
property modern_name -> str;
property important_places -> array<str>;
}
```

## Using functions in queries

Let's also think about our game mechanics a bit. The book says that the doors inside the castle are too tough for Jonathan to open, but Dracula is strong enough to open them all. In a real game it will be more complicated but we can try something simple to mimic this:
Expand Down
4 changes: 2 additions & 2 deletions chapter8/code.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ START MIGRATION TO {
module default {
abstract type Person {
property name -> str {
constraint exclusive;
delegated constraint exclusive;
}
multi link places_visited -> Place;
link lover -> Person;
Expand Down Expand Up @@ -33,7 +33,7 @@ START MIGRATION TO {
abstract type Place {
required property name -> str {
constraint exclusive;
delegated constraint exclusive;
}
property modern_name -> str;
property important_places -> array<str>;
Expand Down
4 changes: 2 additions & 2 deletions chapter9/code.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ START MIGRATION TO {
module default {
abstract type Person {
property name -> str {
constraint exclusive;
delegated constraint exclusive;
}
multi link places_visited -> Place;
multi link lover -> Person;
Expand Down Expand Up @@ -36,7 +36,7 @@ START MIGRATION TO {
abstract type Place {
required property name -> str {
constraint exclusive;
delegated constraint exclusive;
}
property modern_name -> str;
property important_places -> array<str>;
Expand Down
6 changes: 3 additions & 3 deletions chapter9/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ This can be useful if you want a post date when you insert an object. With this
```sdl
abstract type Place {
required property name -> str {
constraint exclusive;
delegated constraint exclusive;
}
property modern_name -> str;
property important_places -> array<str>;
Expand All @@ -109,7 +109,7 @@ This will actually generate the date when you *query* a `Place` object, not when
```sdl
abstract type Place {
required property name -> str {
constraint exclusive;
delegated constraint exclusive;
}
property modern_name -> str;
property important_places -> array<str>;
Expand Down Expand Up @@ -349,7 +349,7 @@ But he has some sort of relationship to Dracula, similar to the `MinorVampire` t
```sdl
abstract type Person {
required property name -> str {
constraint exclusive;
delegated constraint exclusive;
}
property age -> int16;
property strength -> int16;
Expand Down
2 changes: 1 addition & 1 deletion translations/zh/chapter15/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ abstract type HasCoffins {
```sdl
abstract type Place extending HasCoffins {
required property name -> str {
constraint exclusive;
delegated constraint exclusive;
};
property modern_name -> str;
property important_places -> array<str>;
Expand Down
2 changes: 1 addition & 1 deletion translations/zh/chapter17/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ abstract type HasNameAndCoffins {
default := 0;
}
required property name -> str {
constraint exclusive;
delegated constraint exclusive;
constraint max_len_value(30);
}
}
Expand Down
4 changes: 2 additions & 2 deletions translations/zh/chapter20/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ abstract type HasNameAndCoffins {
default := 0;
}
required property name -> str {
constraint exclusive;
delegated constraint exclusive;
constraint max_len_value(30);
}
}
Expand All @@ -66,7 +66,7 @@ abstract type Person {
property title -> str;
property degrees -> str;
required property name -> str {
constraint exclusive
delegated constraint exclusive;
}
property age -> int16;
property conversational_name := .title ++ ' ' ++ .name IF EXISTS .title ELSE .name;
Expand Down
10 changes: 10 additions & 0 deletions translations/zh/chapter7/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ abstract type Person {

有了它,对于扩展自 `Person` 的类型,如 `PC``NPC``Vampire` 等,分别可以拥有最多一个叫做“Jonathan Harker”的对象。

```sdl
abstract type Place {
required property name -> str {
delegated constraint exclusive;
};
property modern_name -> str;
property important_places -> array<str>;
}
```

## 在查询中使用函数

现在让我们来考虑一下我们的游戏机制。书里说城堡里的门对于乔纳森来说太难打开了,但是德古拉足够强壮,可以打开所有。在真正的游戏中,它会更复杂,但我们可以尝试用一些简单的方法来模仿这个事实:
Expand Down
6 changes: 3 additions & 3 deletions translations/zh/chapter9/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ edgedb> SELECT datetime_current();
```sdl
abstract type Place {
required property name -> str {
constraint exclusive;
delegated constraint exclusive;
}
property modern_name -> str;
property important_places -> array<str>;
Expand All @@ -109,7 +109,7 @@ abstract type Place {
```sdl
abstract type Place {
required property name -> str {
constraint exclusive;
delegated constraint exclusive;
}
property modern_name -> str;
property important_places -> array<str>;
Expand Down Expand Up @@ -349,7 +349,7 @@ INSERT NPC {
```sdl
abstract type Person {
required property name -> str {
constraint exclusive;
delegated constraint exclusive;
}
property age -> int16;
property strength -> int16;
Expand Down

0 comments on commit 30d81e3

Please sign in to comment.