Skip to content

Commit ce3fd53

Browse files
authored
Merge pull request #3051 from SeedCompany/edgedb/mitigate-bugs
2 parents 5d46b5d + e813e31 commit ce3fd53

File tree

7 files changed

+127
-33
lines changed

7 files changed

+127
-33
lines changed

dbschema/funding-account.esdl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ module default {
55
}
66

77
required accountNumber: int16 {
8-
constraint min_value(0);
9-
constraint max_value(9);
8+
constraint expression on (__subject__ >= 0 and __subject__ <= 9);
109
}
1110
}
1211
}

dbschema/language.esdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ module default {
8888
}
8989

9090
scalar type population extending int32 {
91-
constraint min_value(0);
91+
constraint expression on (__subject__ >= 0);
9292
}
9393
}
9494

dbschema/migrations/00041.edgeql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CREATE MIGRATION m1xhtylawlv6ksvlfkuw6bien5fobo6mtlj3xgr33uya6hnhcnmn7a
2+
ONTO m1asch4l54f7eltalgtn3ft3kbtgzascsjujcjnonx6yloej5ujkpa
3+
{
4+
alter type default::Project {
5+
alter property departmentId {
6+
drop rewrite update;
7+
};
8+
};
9+
};

dbschema/migrations/00042.edgeql

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
CREATE MIGRATION m1r3t2ku2jysgjliaq54y7saj4tuxecilnajoxgwa2blsb3p64svzq
2+
ONTO m1xhtylawlv6ksvlfkuw6bien5fobo6mtlj3xgr33uya6hnhcnmn7a
3+
{
4+
ALTER TYPE Scripture::Verse {
5+
ALTER PROPERTY chapter {
6+
CREATE CONSTRAINT std::expression ON (((__subject__ >= 1) AND (__subject__ <= 150)));
7+
};
8+
};
9+
ALTER TYPE Scripture::Verse {
10+
ALTER PROPERTY chapter {
11+
DROP CONSTRAINT std::max_value(150);
12+
};
13+
};
14+
ALTER TYPE Scripture::Verse {
15+
ALTER PROPERTY chapter {
16+
DROP CONSTRAINT std::min_value(1);
17+
};
18+
};
19+
ALTER TYPE Scripture::Verse {
20+
ALTER PROPERTY verse {
21+
CREATE CONSTRAINT std::expression ON (((__subject__ >= 1) AND (__subject__ <= 176)));
22+
};
23+
};
24+
ALTER TYPE Scripture::Verse {
25+
ALTER PROPERTY verse {
26+
DROP CONSTRAINT std::max_value(176);
27+
};
28+
};
29+
ALTER TYPE Scripture::Verse {
30+
ALTER PROPERTY verse {
31+
DROP CONSTRAINT std::min_value(1);
32+
};
33+
};
34+
ALTER TYPE Scripture::Verse {
35+
ALTER PROPERTY verseId {
36+
CREATE CONSTRAINT std::expression ON (((__subject__ >= 0) AND (__subject__ <= 31101)));
37+
};
38+
};
39+
ALTER TYPE Scripture::Verse {
40+
ALTER PROPERTY verseId {
41+
DROP CONSTRAINT std::max_value(31101);
42+
};
43+
};
44+
ALTER TYPE Scripture::Verse {
45+
ALTER PROPERTY verseId {
46+
DROP CONSTRAINT std::min_value(0);
47+
};
48+
};
49+
ALTER TYPE default::FundingAccount {
50+
ALTER PROPERTY accountNumber {
51+
CREATE CONSTRAINT std::expression ON (((__subject__ >= 0) AND (__subject__ <= 9)));
52+
};
53+
};
54+
ALTER TYPE default::FundingAccount {
55+
ALTER PROPERTY accountNumber {
56+
DROP CONSTRAINT std::max_value(9);
57+
};
58+
};
59+
ALTER TYPE default::FundingAccount {
60+
ALTER PROPERTY accountNumber {
61+
DROP CONSTRAINT std::min_value(0);
62+
};
63+
};
64+
ALTER TYPE default::Project {
65+
ALTER PROPERTY departmentId {
66+
CREATE CONSTRAINT std::expression ON (((__subject__ >= 10000) AND (__subject__ <= 99999)));
67+
};
68+
};
69+
ALTER TYPE default::Project {
70+
ALTER PROPERTY departmentId {
71+
DROP CONSTRAINT std::max_value(99999);
72+
};
73+
};
74+
ALTER TYPE default::Project {
75+
ALTER PROPERTY departmentId {
76+
DROP CONSTRAINT std::min_value(10000);
77+
};
78+
};
79+
ALTER SCALAR TYPE default::population {
80+
CREATE CONSTRAINT std::expression ON ((__subject__ >= 0));
81+
};
82+
ALTER SCALAR TYPE default::population {
83+
DROP CONSTRAINT std::min_value(0);
84+
};
85+
};

dbschema/project.esdl

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,29 @@ module default {
1212

1313
departmentId: int32 {
1414
constraint exclusive;
15-
constraint min_value(10000);
16-
constraint max_value(99999);
17-
rewrite update using (
18-
if (
19-
not exists .departmentId and
20-
.status <= Project::Status.Active and
21-
.step >= Project::Step.PendingFinanceConfirmation
22-
) then ((
23-
with
24-
fa := assert_exists(
25-
__subject__.primaryLocation.fundingAccount,
26-
message := "Project must have a primary location"
27-
),
28-
existing := (
29-
select detached Project.departmentId filter Project.primaryLocation.fundingAccount = fa
30-
),
31-
available := (
32-
range_unpack(range(fa.accountNumber * 10000 + 11, fa.accountNumber * 10000 + 9999))
33-
except existing
34-
)
35-
select min(available)
36-
)) else .departmentId
37-
);
15+
constraint expression on (__subject__ >= 10000 and __subject__ <= 99999);
16+
# Temporarily disabled. Upstream fix in progress.
17+
# rewrite update using (
18+
# if (
19+
# not exists .departmentId and
20+
# .status <= Project::Status.Active and
21+
# .step >= Project::Step.PendingFinanceConfirmation
22+
# ) then ((
23+
# with
24+
# fa := assert_exists(
25+
# __subject__.primaryLocation.fundingAccount,
26+
# message := "Project must have a primary location"
27+
# ),
28+
# existing := (
29+
# select detached Project.departmentId filter Project.primaryLocation.fundingAccount = fa
30+
# ),
31+
# available := (
32+
# range_unpack(range(fa.accountNumber * 10000 + 11, fa.accountNumber * 10000 + 9999))
33+
# except existing
34+
# )
35+
# select min(available)
36+
# )) else .departmentId
37+
# );
3838
};
3939

4040
required step: Project::Step {
@@ -83,7 +83,10 @@ module default {
8383
link rootDirectory: Directory;
8484

8585
overloaded link projectContext: Project::Context {
86-
default := (insert Project::Context);
86+
default := (insert Project::Context {
87+
# https://github.com/edgedb/edgedb/issues/3960
88+
# projects := {__subject__},
89+
});
8790
}
8891
# Setting the new project as its own context should be the immediate next thing that happens
8992
# So enforce that that happens (as best we can), and assert that the context is ever only itself.

dbschema/scripture.esdl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,15 @@ module Scripture {
3737
}
3838
required chapter: int16 {
3939
readonly := true;
40-
constraint min_value(1);
41-
constraint max_value(150); # Psalms
40+
constraint expression on (__subject__ >= 1 and __subject__ <= 150); # Psalms
4241
}
4342
required verse: int16 {
4443
readonly := true;
45-
constraint min_value(1);
46-
constraint max_value(176); # Psalms 119
44+
constraint expression on (__subject__ >= 1 and __subject__ <= 176); # Psalms 119
4745
}
4846
required verseId: int16 {
4947
readonly := true;
50-
constraint min_value(0);
51-
constraint max_value(31101);
48+
constraint expression on (__subject__ >= 0 and __subject__ <= 31101);
5249
}
5350
}
5451
}

dbschema/seeds/006.translation-projects.edgeql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ select { `Added Projects` := new.name }
6060
filter count(new) > 0;
6161

6262
# Update all projects to self reference for their context (has to be separate query)
63+
# https://github.com/edgedb/edgedb/issues/3960
6364
with updated := (
6465
for project in Project union (
6566
update project.projectContext

0 commit comments

Comments
 (0)