Skip to content

Commit b00b5d3

Browse files
fantixmsullivan
authored andcommitted
Test: add test for enum params in func cache (#8473)
Add test for #8471
1 parent 806f5e5 commit b00b5d3

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

tests/test_server_ops.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,12 @@ def measure_sql_compilations(
744744
) as sd:
745745
con = await sd.connect()
746746
try:
747-
qry = 'select schema::Object { name }'
747+
qry = '''
748+
select schema::Object {
749+
name,
750+
enumval := <cfg::TestEnum>$0,
751+
}
752+
'''
748753
sql = '''
749754
SELECT
750755
n.nspname::text AS table_schema,
@@ -765,12 +770,12 @@ def measure_sql_compilations(
765770
AND n.nspname = 'public';
766771
'''
767772

768-
await con.query(qry)
773+
await con.query(qry, 'Two')
769774
await con.query_sql(sql)
770775

771776
# Querying a second time should hit the cache
772777
with self.assertChange(measure_compilations(sd), 0):
773-
await con.query(qry)
778+
await con.query(qry, 'Two')
774779
with self.assertChange(measure_sql_compilations(sd), 0):
775780
await con.query_sql(sql)
776781

@@ -782,9 +787,9 @@ def measure_sql_compilations(
782787
# the type, so doing the query shouldn't cause another
783788
# compile!
784789
with self.assertChange(measure_compilations(sd), 0):
785-
await con.query(qry)
790+
await con.query(qry, 'Two')
786791
with self.assertChange(measure_compilations(sd), 0):
787-
await con.query(qry)
792+
await con.query(qry, 'Two')
788793

789794
# The SQL cache is reset after DDL, because recompiling SQL
790795
# requires backend connection for amending in/out tids, and
@@ -797,7 +802,7 @@ def measure_sql_compilations(
797802
# TODO: this does not behave the way I thing it should
798803
# with self.assertChange(measure_compilations(sd), 1):
799804
# con_c = con.with_config(apply_access_policies=False)
800-
# await con_c.query(qry)
805+
# await con_c.query(qry, 'Two')
801806

802807
# Set the compilation timeout to 2ms.
803808
#
@@ -823,9 +828,9 @@ def measure_sql_compilations(
823828
''')
824829

825830
with self.assertChange(measure_compilations(sd), 1):
826-
await con.query(qry)
831+
await con.query(qry, 'Two')
827832
with self.assertChange(measure_compilations(sd), 0):
828-
await con.query(qry)
833+
await con.query(qry, 'Two')
829834
with self.assertChange(measure_sql_compilations(sd), 1):
830835
await con.query_sql(sql)
831836
with self.assertChange(measure_sql_compilations(sd), 0):
@@ -873,9 +878,9 @@ def measure_sql_compilations(
873878
create type X
874879
''')
875880
with self.assertChange(measure_compilations(sd), 1):
876-
await con.query(qry)
881+
await con.query(qry, 'Two')
877882
with self.assertChange(measure_compilations(sd), 0):
878-
await con.query(qry)
883+
await con.query(qry, 'Two')
879884
with self.assertChange(measure_sql_compilations(sd), 1):
880885
await con.query_sql(sql)
881886
with self.assertChange(measure_sql_compilations(sd), 0):
@@ -938,7 +943,7 @@ def measure_sql_compilations(
938943
try:
939944
# It should hit the cache no problem.
940945
with self.assertChange(measure_compilations(sd), 0):
941-
await con.query(qry)
946+
await con.query(qry, 'Two')
942947
# TODO(fantix): persistent SQL cache not working?
943948
# with self.assertChange(measure_sql_compilation(sd), 0):
944949
# await con.query_sql(sql)

0 commit comments

Comments
 (0)