Skip to content

Commit 6e8da71

Browse files
jberrymanawjchen
authored andcommitted
server: migrate to aeson-2 in preparation for ghc 9.2 upgrade
(Work here originally done by awjchen, rebased and fixed up for merge by jberryman) This is part of a merge train towards GHC 9.2 compatibility. The main issue is the use of the new abstract `KeyMap` in 2.0. See: https://hackage.haskell.org/package/aeson-2.0.3.0/changelog Alex's original work is here: hasura#4305 BEHAVIOR CHANGE NOTE: This change causes a different arbitrary ordering of serialized Json, for example during metadata export. CLI users care about this in particular, and so we need to call it out as a _behavior change_ as we did in v2.5.0. The good news though is that after this change ordering should be more stable (alphabetical key order). See: https://hasurahq.slack.com/archives/C01M20G1YRW/p1654012632634389 PR-URL: hasura/graphql-engine-mono#4611 Co-authored-by: awjchen <[email protected]> GitOrigin-RevId: 700265162c782739b2bb88300ee3cda3819b2e87
1 parent 0a6671a commit 6e8da71

File tree

93 files changed

+771
-608
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+771
-608
lines changed

.circleci/server-upgrade-downgrade/run.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ get_server_upgrade_tests() {
183183
# feasible to run here
184184
# FIXME: re-enable test_graphql_queries.py::TestGraphQLQueryFunctions
185185
# (fixing "already exists" error) if possible
186+
#
187+
# FIXME: add back `test_limit_orderby_column_query` after next release
186188
python3 -m pytest -q --collect-only --collect-upgrade-tests-to-file "$tmpfile" \
187189
-m 'allow_server_upgrade_test and not skip_server_upgrade_test' \
188190
--deselect test_schema_stitching.py::TestRemoteSchemaBasic::test_introspection \
@@ -200,6 +202,7 @@ get_server_upgrade_tests() {
200202
--deselect test_graphql_queries.py::TestGraphQLQueryFunctions \
201203
--deselect test_graphql_queries.py::TestGraphQLExplainCommon::test_limit_orderby_relationship_query \
202204
--deselect test_graphql_queries.py::TestGraphQLExplainCommon::test_limit_offset_orderby_relationship_query \
205+
--deselect test_graphql_queries.py::TestGraphQLExplainPostgresMSSQLMySQL::test_limit_orderby_column_query \
203206
1>/dev/null 2>/dev/null
204207
set +x
205208
# Choose the subset of jobs to run based on possible parallelism in this buildkite job
@@ -239,6 +242,7 @@ run_server_upgrade_pytest() {
239242
--deselect test_graphql_queries.py::TestGraphQLQueryEnums::test_introspect_user_role \
240243
--deselect test_graphql_queries.py::TestGraphQLExplainCommon::test_limit_orderby_relationship_query \
241244
--deselect test_graphql_queries.py::TestGraphQLExplainCommon::test_limit_offset_orderby_relationship_query \
245+
--deselect test_graphql_queries.py::TestGraphQLExplainPostgresMSSQLMySQL::test_limit_orderby_column_query \
242246
-v $tests_to_run
243247
set +x
244248
cd -

CHANGELOG.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,49 @@ Note: Custom field names and custom table names will override the naming convent
113113
is `graphql-default`, the field names generated will be `my_table`, `my_tableByPk`,
114114
`my_tableAggregate` and so on).
115115

116+
### Behaviour Changes
117+
118+
- cli: change the ordering used for object fields in metadata files to alphabetical order
119+
120+
Example:
121+
<table>
122+
<thead>
123+
<tr>
124+
<th>Server Metadata (JSON)</th>
125+
<th>Old behaviour (YAML)</th>
126+
<th>New Behaviour (YAML)</th>
127+
</tr>
128+
</thead>
129+
<tbody>
130+
<tr>
131+
<td>
132+
<pre>
133+
{
134+
"function": {
135+
"schema": "public",
136+
"name": "search_albums"
137+
}
138+
}
139+
</pre>
140+
</td>
141+
<td>
142+
<pre>
143+
function:
144+
schema: public
145+
name: search_albums
146+
</pre>
147+
</td>
148+
<td>
149+
<pre>
150+
function:
151+
name: search_albums
152+
schema: public
153+
</pre>
154+
</td>
155+
</tr>
156+
</tbody>
157+
</table>
158+
116159
### Bug fixes and improvements
117160

118161
- server: errors from `/healthz` endpoint are now logged with more details

cabal.project.freeze

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ constraints: any.Cabal ==3.2.1.0,
55
any.HTTP ==4000.3.16,
66
HTTP -conduit10 -mtl1 +network-uri -warn-as-error -warp-tests,
77
any.HUnit ==1.6.2.0,
8-
any.OneTuple ==0.3,
8+
any.OneTuple ==0.3.1,
99
any.Only ==0.1,
1010
any.PyF ==0.10.2.0,
1111
PyF -python_test,
@@ -18,7 +18,7 @@ constraints: any.Cabal ==3.2.1.0,
1818
any.Spock-core ==0.14.0.0,
1919
any.StateVar ==1.2.2,
2020
any.adjunctions ==4.4,
21-
any.aeson ==1.5.6.0,
21+
any.aeson ==2.0.3.0,
2222
aeson -bytestring-builder +cffi -developer -fast,
2323
any.aeson-casing ==0.2.0.0,
2424
any.aeson-pretty ==0.8.9,
@@ -45,7 +45,7 @@ constraints: any.Cabal ==3.2.1.0,
4545
attoparsec-iso8601 -developer -fast,
4646
any.authenticate-oauth ==1.7,
4747
any.auto-update ==0.1.6,
48-
any.autodocodec ==0.0.1.0,
48+
any.autodocodec ==0.1.0.0,
4949
any.autodocodec-openapi3 ==0.2.0.0,
5050
any.barbies ==2.0.3.1,
5151
any.base ==4.14.3.0,
@@ -168,10 +168,8 @@ constraints: any.Cabal ==3.2.1.0,
168168
any.ghci ==8.10.7,
169169
any.graphql-parser ==0.2.0.0,
170170
any.happy ==1.20.0,
171-
any.hashable ==1.3.0.0,
171+
any.hashable ==1.3.5.0,
172172
hashable -examples +integer-gmp +sse2 -sse41,
173-
any.hashable-time ==0.2.1,
174-
hashable-time -old-locale,
175173
any.hashtables ==1.2.4.2,
176174
hashtables -bounds-checking -debug -detailed-profiling -portable -sse42 +unsafe-tricks,
177175
any.haskell-lexer ==1.1,
@@ -218,9 +216,9 @@ constraints: any.Cabal ==3.2.1.0,
218216
any.integer-logarithms ==1.0.3.1,
219217
integer-logarithms -check-bounds +integer-gmp,
220218
any.invariant ==0.5.5,
221-
any.ip ==1.7.3,
219+
any.ip ==1.7.4,
222220
any.iproute ==1.7.12,
223-
any.jose ==0.8.5.1,
221+
any.jose ==0.9,
224222
jose -demos,
225223
any.kan-extensions ==5.2.3,
226224
any.keys ==3.12.3,
@@ -248,10 +246,10 @@ constraints: any.Cabal ==3.2.1.0,
248246
any.monad-time ==0.3.1.0,
249247
any.monad-validate ==1.2.0.0,
250248
any.mono-traversable ==1.0.15.3,
251-
any.morpheus-graphql ==0.18.0,
252-
any.morpheus-graphql-app ==0.18.0,
253-
any.morpheus-graphql-code-gen ==0.18.0,
254-
any.morpheus-graphql-core ==0.18.0,
249+
any.morpheus-graphql ==0.19.3,
250+
any.morpheus-graphql-app ==0.19.3,
251+
any.morpheus-graphql-code-gen ==0.19.3,
252+
any.morpheus-graphql-core ==0.19.3,
255253
any.mtl ==2.2.2,
256254
any.mtl-compat ==0.2.2,
257255
mtl-compat -two-point-one -two-point-two,
@@ -295,7 +293,7 @@ constraints: any.Cabal ==3.2.1.0,
295293
pointed +comonad +containers +kan-extensions +semigroupoids +semigroups +stm +tagged +transformers +unordered-containers,
296294
any.port-utils ==0.2.1.0,
297295
any.postgres-options ==0.2.0.0,
298-
any.postgresql-binary ==0.12.4.1,
296+
any.postgresql-binary ==0.12.4.2,
299297
any.postgresql-libpq ==0.9.4.3,
300298
postgresql-libpq -use-pkg-config,
301299
any.postgresql-simple ==0.6.4,
@@ -399,7 +397,7 @@ constraints: any.Cabal ==3.2.1.0,
399397
any.these ==1.1.1.1,
400398
these +assoc,
401399
any.time ==1.9.3,
402-
any.time-compat ==1.9.5,
400+
any.time-compat ==1.9.6.1,
403401
time-compat -old-locale,
404402
any.time-locale-compat ==0.1.1.5,
405403
time-locale-compat -old-locale,
@@ -459,6 +457,7 @@ constraints: any.Cabal ==3.2.1.0,
459457
any.wide-word ==0.1.1.2,
460458
any.witch ==1.0.0.1,
461459
witch -pedantic,
460+
any.witherable ==0.4.2,
462461
any.wl-pprint-annotated ==0.1.0.1,
463462
any.word8 ==0.1.3,
464463
any.wreq ==0.5.3.3,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
- table:
2-
schema: public
32
name: test
3+
schema: public

cli/integration_test/v3/metadata/latest/1_metadata/databases/databases.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
kind: postgres
33
configuration:
44
connection_info:
5-
use_prepared_statements: true
65
database_url:
76
from_env: HASURA_GRAPHQL_DATABASE_URL
87
isolation_level: read-committed
98
pool_settings:
109
connection_lifetime: 600
11-
retries: 1
1210
idle_timeout: 180
1311
max_connections: 50
12+
retries: 1
13+
use_prepared_statements: true
1414
tables: "!include default/tables/tables.yaml"

cli/integration_test/v3/metadata/latest/2_metadata/databases/databases.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
kind: postgres
33
configuration:
44
connection_info:
5-
use_prepared_statements: true
65
database_url:
76
from_env: HASURA_GRAPHQL_DATABASE_URL
87
isolation_level: read-committed
98
pool_settings:
109
connection_lifetime: 600
11-
retries: 1
1210
idle_timeout: 180
1311
max_connections: 50
12+
retries: 1
13+
use_prepared_statements: true
1414
tables: "!include default/tables/tables.yaml"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
table:
2-
schema: public
32
name: test
3+
schema: public

cli/pkg/metadata/project_metadata_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ func TestProjectMetadataOps_Apply(t *testing.T) {
2525
projectDirectory string
2626
endpointString string
2727
}
28+
// Named for reuse below. We only care about the inconsistent_objects array
29+
// as a set, i.e. ordering may change:
30+
v3Expected :=
31+
`{"is_consistent":false,"inconsistent_objects":[
32+
{"definition":{"name":"t2","schema":"public"},"name":"table t2 in source default","reason":"Inconsistent object: no such table/view exists in source: \"t2\"","type":"table"},
33+
{"definition":{"name":"t4","schema":"pub"},"name":"table pub.t4 in source default","reason":"Inconsistent object: no such table/view exists in source: \"pub.t4\"","type":"table"},
34+
{"definition":{"name":"t3","schema":"pub"},"name":"table pub.t3 in source default","reason":"Inconsistent object: no such table/view exists in source: \"pub.t3\"","type":"table"},
35+
{"definition":{"name":"t1","schema":"public"},"name":"table t1 in source default","reason":"Inconsistent object: no such table/view exists in source: \"t1\"","type":"table"}
36+
]}`
2837
tests := []struct {
2938
name string
3039
fields fields
@@ -37,7 +46,7 @@ func TestProjectMetadataOps_Apply(t *testing.T) {
3746
projectDirectory: "testdata/projectv3",
3847
endpointString: hgeEndpoint,
3948
},
40-
`{"is_consistent":false,"inconsistent_objects":[{"definition":{"name":"t1","schema":"public"},"name":"table t1 in source default","reason":"Inconsistent object: no such table/view exists in source: \"t1\"","type":"table"},{"definition":{"name":"t2","schema":"public"},"name":"table t2 in source default","reason":"Inconsistent object: no such table/view exists in source: \"t2\"","type":"table"},{"definition":{"name":"t4","schema":"pub"},"name":"table pub.t4 in source default","reason":"Inconsistent object: no such table/view exists in source: \"pub.t4\"","type":"table"},{"definition":{"name":"t3","schema":"pub"},"name":"table pub.t3 in source default","reason":"Inconsistent object: no such table/view exists in source: \"pub.t3\"","type":"table"}]}`,
49+
v3Expected,
4150
false,
4251
},
4352
{
@@ -46,7 +55,7 @@ func TestProjectMetadataOps_Apply(t *testing.T) {
4655
projectDirectory: "testdata/projectv3-file-mode-json",
4756
endpointString: hgeEndpoint,
4857
},
49-
`{"is_consistent":false,"inconsistent_objects":[{"definition":{"name":"t1","schema":"public"},"name":"table t1 in source default","reason":"Inconsistent object: no such table/view exists in source: \"t1\"","type":"table"},{"definition":{"name":"t2","schema":"public"},"name":"table t2 in source default","reason":"Inconsistent object: no such table/view exists in source: \"t2\"","type":"table"},{"definition":{"name":"t4","schema":"pub"},"name":"table pub.t4 in source default","reason":"Inconsistent object: no such table/view exists in source: \"pub.t4\"","type":"table"},{"definition":{"name":"t3","schema":"pub"},"name":"table pub.t3 in source default","reason":"Inconsistent object: no such table/view exists in source: \"pub.t3\"","type":"table"}]}`,
58+
v3Expected,
5059
false,
5160
},
5261
{
@@ -55,7 +64,7 @@ func TestProjectMetadataOps_Apply(t *testing.T) {
5564
projectDirectory: "testdata/projectv3-file-mode-yaml",
5665
endpointString: hgeEndpoint,
5766
},
58-
`{"is_consistent":false,"inconsistent_objects":[{"definition":{"name":"t1","schema":"public"},"name":"table t1 in source default","reason":"Inconsistent object: no such table/view exists in source: \"t1\"","type":"table"},{"definition":{"name":"t2","schema":"public"},"name":"table t2 in source default","reason":"Inconsistent object: no such table/view exists in source: \"t2\"","type":"table"},{"definition":{"name":"t4","schema":"pub"},"name":"table pub.t4 in source default","reason":"Inconsistent object: no such table/view exists in source: \"pub.t4\"","type":"table"},{"definition":{"name":"t3","schema":"pub"},"name":"table pub.t3 in source default","reason":"Inconsistent object: no such table/view exists in source: \"pub.t3\"","type":"table"}]}`,
67+
v3Expected,
5968
false,
6069
},
6170
{

cli/pkg/metadata/testdata/get_inconsistent_metadata_test/can_list_inconsistent_metadata_config_v3.golden.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
{
22
"is_consistent": false,
33
"inconsistent_objects": [
4-
{
5-
"definition": {
6-
"schema": "public",
7-
"name": "t1"
8-
},
9-
"reason": "Inconsistent object: no such table/view exists in source: \"t1\"",
10-
"name": "table t1 in source default",
11-
"type": "table"
12-
},
134
{
145
"definition": {
156
"schema": "public",
@@ -36,6 +27,15 @@
3627
"reason": "Inconsistent object: no such table/view exists in source: \"pub.t3\"",
3728
"name": "table pub.t3 in source default",
3829
"type": "table"
30+
},
31+
{
32+
"definition": {
33+
"schema": "public",
34+
"name": "t1"
35+
},
36+
"reason": "Inconsistent object: no such table/view exists in source: \"t1\"",
37+
"name": "table t1 in source default",
38+
"type": "table"
3939
}
4040
]
41-
}
41+
}

cli/pkg/metadata/testdata/metadata_diff_test/config_v3_diff

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
- server
22
+ project
3-
@@ -4,22 +4,29 @@
4-
- use_prepared_statements: true
5-
- retries: 1
3+
@@ -13,13 +13,20 @@
64
- tables: []
7-
+ retries: 1
8-
+ use_prepared_statements: true
95
+ tables:
106
+ - table:
117
+ name: t3

packaging/cli-migrations/v2/test/validation/metadata.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@
77
"tables": [
88
{
99
"table": {
10-
"schema": "public",
11-
"name": "test"
10+
"name": "test",
11+
"schema": "public"
1212
}
1313
}
1414
],
1515
"configuration": {
1616
"connection_info": {
17-
"use_prepared_statements": true,
1817
"database_url": {
1918
"from_env": "HASURA_GRAPHQL_DATABASE_URL"
2019
},
2120
"isolation_level": "read-committed",
2221
"pool_settings": {
2322
"connection_lifetime": 600,
24-
"retries": 1,
2523
"idle_timeout": 180,
26-
"max_connections": 50
27-
}
24+
"max_connections": 50,
25+
"retries": 1
26+
},
27+
"use_prepared_statements": true
2828
}
2929
}
3030
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"settings": {
3-
"migration_mode": "true"
4-
},
52
"isStateCopyCompleted": true,
63
"migrations": {
74
"default": {
85
"1616826329751": false
96
}
7+
},
8+
"settings": {
9+
"migration_mode": "true"
1010
}
1111
}

packaging/cli-migrations/v3/test/validation/metadata.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@
77
"tables": [
88
{
99
"table": {
10-
"schema": "public",
11-
"name": "test"
10+
"name": "test",
11+
"schema": "public"
1212
}
1313
}
1414
],
1515
"configuration": {
1616
"connection_info": {
17-
"use_prepared_statements": false,
1817
"database_url": {
1918
"from_env": "HASURA_GRAPHQL_DATABASE_URL"
2019
},
2120
"isolation_level": "read-committed",
2221
"pool_settings": {
2322
"connection_lifetime": 600,
24-
"retries": 1,
2523
"idle_timeout": 180,
26-
"max_connections": 50
27-
}
24+
"max_connections": 50,
25+
"retries": 1
26+
},
27+
"use_prepared_statements": false
2828
}
2929
}
3030
}

scripts/data-sources-util.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,13 @@ function add_postgres_source() {
3131

3232
echo ""
3333
echo "Adding Postgres source"
34-
curl --fail "$metadata_url" \
35-
--data-raw '{"type":"pg_add_source","args":{"name":"default","configuration":{"connection_info":{"database_url":"'"$db_url"'"}}}}'
34+
# FIXME: Without a loop here `dev.sh test` fails for me here. With the loop
35+
# I get “source with name \"default\" already exists”
36+
until curl -s "$metadata_url" \
37+
--data-raw '{"type":"pg_add_source","args":{"name":"default","configuration":{"connection_info":{"database_url":"'"$db_url"'"}}}}'; &>/dev/null; do
38+
echo -n '.' && sleep 0.2
39+
done
40+
echo " Ok"
3641
}
3742

3843
function add_citus_source() {

scripts/dev.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,6 @@ elif [ "$MODE" = "test" ]; then
545545
fi
546546
done
547547

548-
echo ""
549548
echo " Ok"
550549

551550
add_sources $HASURA_GRAPHQL_SERVER_PORT

0 commit comments

Comments
 (0)