Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column 'createdon' does not allow DBNull.Value. #492

Closed
fowl2 opened this issue Jun 20, 2024 · 3 comments
Closed

Column 'createdon' does not allow DBNull.Value. #492

fowl2 opened this issue Jun 20, 2024 · 3 comments

Comments

@fowl2
Copy link
Contributor

fowl2 commented Jun 20, 2024

Somehow, I've got an null createdon, and SQL 4 CDS does not like it.

I can't select that column on any row without receiving "Column 'createdon' does not allow DBNull.Value."

select top 1 
createdon
 from solutioncomponent
 where createdon is null
<fetch xmlns:generator='MarkMpn.SQL4CDS' top='1'>
  <entity name='solutioncomponent'>
    <attribute name='createdon' />
    <filter>
      <condition attribute='createdon' operator='null' />
    </filter>
  </entity>
</fetch>

XrmToolBox 1.2023.12.68
SQL4CDS 9.1.0.0 (happened in 9.0 as well, not sure about previously)

@fowl2
Copy link
Contributor Author

fowl2 commented Jun 20, 2024

Can trace it down to here, where it seems that createdon is hardcoded as not nullable:

var notNull = innerJoin && (attrMetadata.LogicalName == entityMetadata.PrimaryIdAttribute || attrMetadata.LogicalName == "createdon");

Looks like this has recently been a problem with createdby as well: 5c688bc

But really, the question I'm asking myself is why we're performing schema validation on results at all? Is it to ensure the integrity of any optimization of operations/joins/updates etc?

@MarkMpn
Copy link
Owner

MarkMpn commented Jun 20, 2024

Thanks!

For background:

Internally we can use the nullability of a column to apply different optimizations, and we also expose the schema information from the Sql4CdsDataReader so the consuming application, whether that's the SQL 4 CDS tool itself or other applications, can make use of it as necessary.

In the XrmToolBox tool, the results are loaded into a DataTable that is then bound to the grid for display. The DataTable uses the exposed schema information to apply constraints on its own columns, which then produces this error when the data is loaded.

@MarkMpn
Copy link
Owner

MarkMpn commented Jun 20, 2024

Fixed in #493

@MarkMpn MarkMpn closed this as completed Jun 20, 2024
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

No branches or pull requests

2 participants