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

All code to support non-comparable columns #941

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

SvdSinner
Copy link
Contributor

@SvdSinner SvdSinner commented Jan 23, 2023

This replaces pull requests #938 and #923.

Fixes issue: #910

@Mimetis
Copy link
Owner

Mimetis commented Jan 24, 2023

The problem I see here is that all tests passed because the Adventureworks generated database has no xml or ntext column actually.

You can change that by specifying that one column from one table (that is filtered) has a ntext column instead of varchar()

Like for example SalesOrderHeader has a column Comment, that you can use for that in AdventureWorksContext.cs, you can add this property (around line 600):

if (this.ProviderType == ProviderType.Sql)
    entity.Property(e => e.Comment).HasColumnType("ntext");

That way, the Comment field will be generated as a ntext column:

image

Once you have modified the database generation, you will see that errors are showing up ;)

@SvdSinner
Copy link
Contributor Author

I forgot to mention that I had found some bugs that I'm working out. I tried using DMS on a 15 yr old database that was designed by people who had no idea what they were doing. It has everything ugly in it: Text, NText, Image columns, Tables with no primary keys, column names with special characters and very little referential integrity.

It is a dumpster-fire of a database, but it's been great for testing and finding edge cases. Once I work threw all the issues, I will make a commit with the fixes for everything I have found.

@SvdSinner
Copy link
Contributor Author

I think this is ready for merging. There are still a few failing tests (below) that I do not think are related to anything in this PR.

Still failing (Net 6.0) tests:
SqlServerChangeTrackingHttpFilterTests.DeleteTwoRowsInTwoTablesOnClientSide
SqlServerTcpFilterTests.DeleteTwoRowsInTwoTablesOnClientSide
SqlServerUnitRemoteOrchestratprTests.RemoteOrchestrator_HttpGetChanges_WithFilters_ShouldReturnDeletedRowsCount
SqlServerUnitRemoteOrchestratorTests.RemoteOrchestrator_HttpGetEstimatedChanges_WithFilters_ShouldReturnDeletedRowsCount

@SvdSinner
Copy link
Contributor Author

I've merged in all recent changes and re-ran all the tests. There is now only one failing test (Net 6.0):
SqlServerTcpFilterTests.DeleteTwoRowsInTwoTablesOnClientSide
Again, I don't think this PR has anything at all to do with that test, so I don't believe the failure is relevant.

@RaniRishmawi
Copy link

Hello team, first I would like to thank all the maintainers for a great library. however, I am facing the issue of ntext type not being supported. I believe this issue has to do with it. Is this to be released soon? Is there anything that I can help with to move this fix to Nuget packages?

@Mimetis
Copy link
Owner

Mimetis commented Jun 14, 2023

ntext, text and image will be removed in the future versions of SQL Server. (https://learn.microsoft.com/en-us/sql/t-sql/data-types/ntext-text-and-image-transact-sql?view=sql-server-ver16)

This PR adds the support of these types, but with a lot of complexicity.
It's a great feature, but I believe we should not add it tot the next release of DMS, for multiple reasons.

I believe we should encourage people to migrate to nvarchar(max) or varbinary(max) instead of using these old, non performant, types.
The support of these types in DMS adds a lot of complexity with some tradeoffs.

I think it's a good example, as a provider, but should not be add to the core source of DMS (especially in SqlSyncProvider)

@SvdSinner
Copy link
Contributor Author

SvdSinner commented Jul 6, 2023

ntext, text and image will be removed in the future versions of SQL Server. . . This PR adds the support of these types, but with a lot of complexicity.

Much more importantly, this PR adds support for XML columns which are a first class SQL object that will continue being used well into the future. ntext, text and image support is just there because it takes no extra effort to support them if you are already supporting XML columns.

Also, given that ntext, text and image support haven't been a best practice since 2005 when NVARCHAR(MAX), VARCHAR(MAX) and VARBINARY(MAX) came out yet they still exist in the wild, it is a good idea to support them. Databases often move at glacial paces and still contain stuff designed pre-2005 because there hasn't been a business case to update them.

*** (Personal request) Since this is critical code for what I'm using this for, if this doesn't get merged in, it will make my future pull requests of other features that I have added extremely difficult if I need to keep all of these changes out of future pull requests. I enjoy giving back to this project, and I'd love if you kept that as an easy option for me by keep our source trees similar.

@SvdSinner
Copy link
Contributor Author

SvdSinner commented Jul 6, 2023

Hello team, first I would like to thank all the maintainers for a great library. however, I am facing the issue of ntext type not being supported. I believe this issue has to do with it. Is this to be released soon? Is there anything that I can help with to move this fix to Nuget packages?

Until it is merged, you are welcome to use the source code from the source of this pull request

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.

None yet

3 participants