Skip to content

Conversation

@lucyzhang929
Copy link
Contributor

Fixes: #270

{
foreach (string unsupportedType in UnsupportedTypes)
{
if (columns[property].StartsWith(unsupportedType, StringComparison.OrdinalIgnoreCase))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to use StartsWith instead of comparing the whole string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The column type also includes the size, for example text(10).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you have sizes for these types? I tried and it gave me an error

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, the value I got while testing was text() so I thought there can be sizes. Maybe the column type returned will always be text(), ntext(), and image(). I'll double check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The (*) gets added on because of this line in the query

when CHARACTER_MAXIMUM_LENGTH <> -1 then '(' + cast(CHARACTER_MAXIMUM_LENGTH as varchar(4)) + ')'
I updated the UnsupportedTypes to include the (*) and simplified the check.

@lucyzhang929 lucyzhang929 merged commit 7f44c86 into main Feb 9, 2023
@lucyzhang929 lucyzhang929 deleted the luczhan/unsupportedtypes branch February 9, 2023 00:30
PBBlox pushed a commit to PBBlox/azure-functions-sql-extension that referenced this pull request Apr 6, 2025
* throw custom error for unsupported types

* add ntext & image to test + cleanup

* fix powershell ordering

* Update src/SqlAsyncCollector.cs

Co-authored-by: Charles Gagnon <chgagnon@microsoft.com>

* update column names

* fix tests

* simplify

---------

Co-authored-by: Charles Gagnon <chgagnon@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make error message clearer when using unsupported column types

4 participants