Skip to content

Commit e37fe4d

Browse files
Abel Milashclaude
andcommitted
Fix async example scripts: remove deprecated method calls and close session on auth failure
- functional_testing.py: replace batch.records.get() with batch.records.retrieve(); close client session on auth failure to avoid unclosed session warning - sql_examples.py: remove odata_select/odata_expand/odata_bind calls (deprecated sync-only helpers not available on async client); keep only odata_expands() Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 6c32c6b commit e37fe4d

2 files changed

Lines changed: 10 additions & 29 deletions

File tree

examples/aio/advanced/sql_examples.py

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
- AND/OR, NOT IN, NOT LIKE boolean logic
2626
- Deep JOINs (5-8 tables) with no server depth limit
2727
- SQL helper functions: sql_columns (sql_select/sql_join/sql_joins removed at GA)
28-
- OData helper functions: odata_select, odata_expands, odata_expand, odata_bind
28+
- OData helper functions: odata_expands (odata_select/odata_expand/odata_bind are sync-only deprecated helpers)
2929
- SQL vs OData side-by-side comparison
3030
3131
Not supported (server rejects):
@@ -935,18 +935,13 @@ async def _run_examples(client):
935935
# ==============================================================
936936
# 30. OData Helper Functions
937937
# ==============================================================
938-
heading(30, "OData Helper Functions (query.odata_* — deprecated at GA)")
938+
heading(30, "OData Helper Functions (query.odata_expands)")
939939
print(
940-
"odata_select(), odata_expand(), and odata_bind() still work at GA\n"
941-
"but emit DeprecationWarning. Use the typed query builder instead.\n"
942-
"odata_expands() is kept without deprecation."
940+
"odata_expands() discovers navigation properties for $expand and @odata.bind.\n"
941+
"odata_select(), odata_expand(), and odata_bind() are deprecated sync-only helpers\n"
942+
"not available on the async client. Use sql_columns() and odata_expands() instead."
943943
)
944944

945-
# odata_select
946-
log_call(f"client.query.odata_select('{parent_table}')")
947-
odata_cols = await client.query.odata_select(parent_table)
948-
print(f"[OK] {len(odata_cols)} columns for $select: {odata_cols[:5]}...")
949-
950945
# odata_expands
951946
log_call(f"client.query.odata_expands('{child_table}')")
952947
try:
@@ -957,23 +952,6 @@ async def _run_examples(client):
957952
except Exception as e:
958953
print(f"[WARN] {e}")
959954

960-
# odata_expand (single target)
961-
try:
962-
nav = await client.query.odata_expand(child_table, parent_table)
963-
print(f"\n[OK] odata_expand('{child_table}', '{parent_table}') = '{nav}'")
964-
print(" Usage: client.query.builder('" + child_table + "').expand('" + nav + "').execute()")
965-
except Exception as e:
966-
print(f"[WARN] {e}")
967-
968-
# odata_bind
969-
log_call("client.query.odata_bind(...)")
970-
try:
971-
bind = await client.query.odata_bind(child_table, parent_table, team_ids[0])
972-
print(f"[OK] {bind}")
973-
print(" Merge into create/update payload: {{'new_Title': 'X', **bind}}")
974-
except Exception as e:
975-
print(f"[WARN] {e}")
976-
977955
# ==============================================================
978956
# 31. SQL vs OData Comparison
979957
# ==============================================================

examples/aio/basic/functional_testing.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ async def setup_authentication():
9494
print("=" * 50)
9595

9696
org_url = get_dataverse_org_url()
97+
client = None
9798
try:
9899
credential = AsyncInteractiveBrowserCredential()
99100
client = AsyncDataverseClient(org_url, credential)
@@ -111,6 +112,8 @@ async def setup_authentication():
111112

112113
except Exception as e:
113114
print(f"[ERR] Authentication failed: {e}")
115+
if client is not None:
116+
await client.aclose()
114117
sys.exit(1)
115118

116119

@@ -790,12 +793,12 @@ async def test_batch_all_operations(client: AsyncDataverseClient, table_info: Di
790793
if all_ids:
791794
print(f"\n[10/11] Mixed batch (continue_on_error=True) — 1 bad get + 1 good get")
792795
batch = client.batch.new()
793-
batch.records.get(
796+
batch.records.retrieve(
794797
table_schema_name,
795798
"00000000-0000-0000-0000-000000000002",
796799
select=[f"{attr_prefix}_name"],
797800
)
798-
batch.records.get(
801+
batch.records.retrieve(
799802
table_schema_name,
800803
all_ids[0],
801804
select=[f"{attr_prefix}_name"],

0 commit comments

Comments
 (0)