Skip to content

Commit d28c960

Browse files
author
Samson Gebre
committed
Merge remote-tracking branch 'origin/main' into users/sagebree/issue157_fix_sql_truncation
2 parents d637725 + 29eabae commit d28c960

8 files changed

Lines changed: 79 additions & 8 deletions

File tree

.claude/skills/dataverse-sdk-use/SKILL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ table_info = client.tables.create(
250250
#### Supported Column Types
251251
Types on the same line map to the same exact format under the hood
252252
- `"string"` or `"text"` - Single line of text
253+
- `"memo"` or `"multiline"` - Multiple lines of text (4000 character default)
253254
- `"int"` or `"integer"` - Whole number
254255
- `"decimal"` or `"money"` - Decimal number
255256
- `"float"` or `"double"` - Floating point number

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ for page in client.records.get(
404404
# Create a custom table, including the customization prefix value in the schema names for the table and columns.
405405
table_info = client.tables.create("new_Product", {
406406
"new_Code": "string",
407+
"new_Description": "memo",
407408
"new_Price": "decimal",
408409
"new_Active": "bool"
409410
})
@@ -674,7 +675,7 @@ For optimal performance in production environments:
674675
### Limitations
675676

676677
- SQL queries are **read-only** and support a limited subset of SQL syntax
677-
- Create Table supports a limited number of column types (string, int, decimal, bool, datetime, picklist)
678+
- Create Table supports the following column types: string, memo, int, decimal, float, bool, datetime, file, and picklist (Enum subclass)
678679
- File uploads are limited by Dataverse file size restrictions (default 128MB per file)
679680

680681
## Contributing

examples/advanced/walkthrough.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ def _run_walkthrough(client):
120120
"new_Quantity": "int",
121121
"new_Amount": "decimal",
122122
"new_Completed": "bool",
123+
"new_Notes": "memo",
123124
"new_Priority": Priority,
124125
}
125126
table_info = backoff(lambda: client.tables.create(table_name, columns))
@@ -140,6 +141,7 @@ def _run_walkthrough(client):
140141
"new_Quantity": 5,
141142
"new_Amount": 1250.50,
142143
"new_Completed": False,
144+
"new_Notes": "This is a multiline memo field.\nIt supports longer text content.",
143145
"new_Priority": Priority.MEDIUM,
144146
}
145147
id1 = backoff(lambda: client.records.create(table_name, single_record))
@@ -192,6 +194,7 @@ def _run_walkthrough(client):
192194
"new_quantity": record.get("new_quantity"),
193195
"new_amount": record.get("new_amount"),
194196
"new_completed": record.get("new_completed"),
197+
"new_notes": record.get("new_notes"),
195198
"new_priority": record.get("new_priority"),
196199
"new_priority@FormattedValue": record.get("new_priority@OData.Community.Display.V1.FormattedValue"),
197200
},
@@ -218,9 +221,19 @@ def _run_walkthrough(client):
218221

219222
# Single update
220223
log_call(f"client.records.update('{table_name}', '{id1}', {{...}})")
221-
backoff(lambda: client.records.update(table_name, id1, {"new_Quantity": 100}))
224+
backoff(
225+
lambda: client.records.update(
226+
table_name,
227+
id1,
228+
{
229+
"new_Quantity": 100,
230+
"new_Notes": "Updated memo field.\nNow with revised content across multiple lines.",
231+
},
232+
)
233+
)
222234
updated = backoff(lambda: client.records.get(table_name, id1))
223235
print(f"[OK] Updated single record new_Quantity: {updated.get('new_quantity')}")
236+
print(f" new_Notes: {repr(updated.get('new_notes'))}")
224237

225238
# Multiple update (broadcast same change)
226239
log_call(f"client.records.update('{table_name}', [{len(ids)} IDs], {{...}})")
@@ -462,14 +475,14 @@ def _run_walkthrough(client):
462475
print("11. Column Management")
463476
print("=" * 80)
464477

465-
log_call(f"client.tables.add_columns('{table_name}', {{'new_Notes': 'string'}})")
466-
created_cols = backoff(lambda: client.tables.add_columns(table_name, {"new_Notes": "string"}))
478+
log_call(f"client.tables.add_columns('{table_name}', {{'new_Tags': 'string'}})")
479+
created_cols = backoff(lambda: client.tables.add_columns(table_name, {"new_Tags": "string"}))
467480
print(f"[OK] Added column: {created_cols[0]}")
468481

469482
# Delete the column we just added
470-
log_call(f"client.tables.remove_columns('{table_name}', ['new_Notes'])")
471-
backoff(lambda: client.tables.remove_columns(table_name, ["new_Notes"]))
472-
print(f"[OK] Deleted column: new_Notes")
483+
log_call(f"client.tables.remove_columns('{table_name}', ['new_Tags'])")
484+
backoff(lambda: client.tables.remove_columns(table_name, ["new_Tags"]))
485+
print(f"[OK] Deleted column: new_Tags")
473486

474487
# ============================================================================
475488
# 12. DELETE OPERATIONS

src/PowerPlatform/Dataverse/claude_skill/dataverse-sdk-use/SKILL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ table_info = client.tables.create(
250250
#### Supported Column Types
251251
Types on the same line map to the same exact format under the hood
252252
- `"string"` or `"text"` - Single line of text
253+
- `"memo"` or `"multiline"` - Multiple lines of text (4000 character default)
253254
- `"int"` or `"integer"` - Whole number
254255
- `"decimal"` or `"money"` - Decimal number
255256
- `"float"` or `"double"` - Floating point number

src/PowerPlatform/Dataverse/data/_odata.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,16 @@ def _attribute_payload(
13681368
"FormatName": {"Value": "Text"},
13691369
"IsPrimaryName": bool(is_primary_name),
13701370
}
1371+
if dtype_l in ("memo", "multiline"):
1372+
return {
1373+
"@odata.type": "Microsoft.Dynamics.CRM.MemoAttributeMetadata",
1374+
"SchemaName": column_schema_name,
1375+
"DisplayName": self._label(label),
1376+
"RequiredLevel": {"Value": "None"},
1377+
"MaxLength": 4000,
1378+
"FormatName": {"Value": "Text"},
1379+
"ImeMode": "Auto",
1380+
}
13711381
if dtype_l in ("int", "integer"):
13721382
return {
13731383
"@odata.type": "Microsoft.Dynamics.CRM.IntegerAttributeMetadata",

src/PowerPlatform/Dataverse/operations/tables.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ def create(
8282
:type table: :class:`str`
8383
:param columns: Mapping of column schema names (with customization
8484
prefix) to their types. Supported types include ``"string"``
85-
(or ``"text"``), ``"int"`` (or ``"integer"``), ``"decimal"``
85+
(or ``"text"``), ``"memo"`` (or ``"multiline"``),
86+
``"int"`` (or ``"integer"``), ``"decimal"``
8687
(or ``"money"``), ``"float"`` (or ``"double"``), ``"datetime"``
8788
(or ``"date"``), ``"bool"`` (or ``"boolean"``), ``"file"``, and
8889
``Enum`` subclasses

tests/unit/data/test_odata_internal.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,40 @@ def test_returns_none(self):
519519
self.assertIsNone(result)
520520

521521

522+
class TestAttributePayload(unittest.TestCase):
523+
"""Unit tests for _ODataClient._attribute_payload."""
524+
525+
def setUp(self):
526+
self.od = _make_odata_client()
527+
528+
def test_memo_type(self):
529+
"""'memo' should produce MemoAttributeMetadata with MaxLength 4000."""
530+
result = self.od._attribute_payload("new_Notes", "memo")
531+
self.assertEqual(result["@odata.type"], "Microsoft.Dynamics.CRM.MemoAttributeMetadata")
532+
self.assertEqual(result["SchemaName"], "new_Notes")
533+
self.assertEqual(result["MaxLength"], 4000)
534+
self.assertEqual(result["FormatName"], {"Value": "Text"})
535+
self.assertNotIn("IsPrimaryName", result)
536+
537+
def test_multiline_alias(self):
538+
"""'multiline' should produce identical payload to 'memo'."""
539+
memo_result = self.od._attribute_payload("new_Description", "memo")
540+
multiline_result = self.od._attribute_payload("new_Description", "multiline")
541+
self.assertEqual(multiline_result, memo_result)
542+
543+
def test_string_type(self):
544+
"""'string' should produce StringAttributeMetadata with MaxLength 200."""
545+
result = self.od._attribute_payload("new_Title", "string")
546+
self.assertEqual(result["@odata.type"], "Microsoft.Dynamics.CRM.StringAttributeMetadata")
547+
self.assertEqual(result["MaxLength"], 200)
548+
self.assertEqual(result["FormatName"], {"Value": "Text"})
549+
550+
def test_unsupported_type_returns_none(self):
551+
"""An unknown type string should return None."""
552+
result = self.od._attribute_payload("new_Col", "unknown_type")
553+
self.assertIsNone(result)
554+
555+
522556
class TestPicklistLabelResolution(unittest.TestCase):
523557
"""Tests for picklist label-to-integer resolution.
524558

tests/unit/test_tables_operations.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,16 @@ def test_add_columns(self):
193193
self.client._odata._create_columns.assert_called_once_with("new_Product", columns)
194194
self.assertEqual(result, ["new_Notes", "new_Active"])
195195

196+
def test_add_columns_memo(self):
197+
"""add_columns() with memo type should pass through correctly."""
198+
self.client._odata._create_columns.return_value = ["new_Description"]
199+
200+
columns = {"new_Description": "memo"}
201+
result = self.client.tables.add_columns("new_Product", columns)
202+
203+
self.client._odata._create_columns.assert_called_once_with("new_Product", columns)
204+
self.assertEqual(result, ["new_Description"])
205+
196206
# --------------------------------------------------------- remove_columns
197207

198208
def test_remove_columns_single(self):

0 commit comments

Comments
 (0)