fsprojects / SQLProvider

A general F# SQL database erasing type provider, supporting LINQ queries, schema exploration, individuals, CRUD operations and much more besides.
https://fsprojects.github.io/SQLProvider
Other
564 stars 144 forks source link

Build error when upgrading from 1.1.91 to 1.1.92 #693

Closed JordanMarr closed 3 years ago

JordanMarr commented 3 years ago

Describe the bug After upgrading from v1.1.91 to 1.1.92 I get the following build error:

The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: The data contract type 'FSharp.Data.Sql.Schema.Column' cannot be deserialized because the required data member 'IsComputed@' was not found.

To Reproduce Steps to reproduce the behavior:

  1. Upgrade to latest version and try to build project

Expected behavior Should build.

Desktop (please complete the following information):

Additional context Reverting to v1.1.91 fixes the problem. Database is SQL Server 2017.

Thorium commented 3 years ago

Thanks for reporting, I need bit of your help to sort this out... Basically this is the query we are using, with the IsComputed as added (line 5):

SELECT c.COLUMN_NAME,c.DATA_TYPE, c.character_maximum_length, c.numeric_precision, c.is_nullable
            ,CASE WHEN pk.COLUMN_NAME IS NOT NULL THEN 'PRIMARY KEY' ELSE '' END AS KeyType
            ,COLUMNPROPERTY(OBJECT_ID(c.TABLE_SCHEMA + '.' + c.TABLE_NAME), c.COLUMN_NAME, 'IsIdentity') AS IsIdentity, 
            case when COLUMN_DEFAULT is not null then 1 else 0 end as HasDefault,
            COLUMNPROPERTY(OBJECT_ID(c.TABLE_SCHEMA+'.'+c.TABLE_NAME), c.COLUMN_NAME, 'IsComputed') AS IsComputed
FROM INFORMATION_SCHEMA.COLUMNS c
LEFT JOIN (
            SELECT ku.TABLE_CATALOG,ku.TABLE_SCHEMA,ku.TABLE_NAME,ku.COLUMN_NAME
            FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS tc
            INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS ku
                ON tc.CONSTRAINT_TYPE = 'PRIMARY KEY'
                AND tc.CONSTRAINT_NAME = ku.CONSTRAINT_NAME
        )   pk
ON  c.TABLE_CATALOG = pk.TABLE_CATALOG
            AND c.TABLE_SCHEMA = pk.TABLE_SCHEMA
            AND c.TABLE_NAME = pk.TABLE_NAME
            AND c.COLUMN_NAME = pk.COLUMN_NAME
--WHERE c.TABLE_SCHEMA = @schema AND c.TABLE_NAME = @table
ORDER BY c.TABLE_SCHEMA,c.TABLE_NAME, c.ORDINAL_POSITION

This is working with select @@version as version reporting Microsoft SQL Azure (RTM) - 12.0.2000.8 Could you identify a query that would pick computed column property from INFORMATION_SCHEMA.COLUMNS with your version? If not, then we have to at least get a query that won't crash.

JordanMarr commented 3 years ago

I ran this query directly in SSMS and it runs fine.

Thorium commented 3 years ago

Weird. Can this be a caching problem of some kind? I expect you didn't have VS open during the upgrade?

JordanMarr commented 3 years ago

It was the cached .schema file. I had to delete it and allow it to be regenerated for the update to work. Thanks.