azuredatastudio: Schema Compare tool showing objects as changed but no differences displayed in the diff itself (potential line ending mismatch)

  • Azure Data Studio Version:
Version: 1.37.0
Commit: d904740d93d7df76a0ba361f20e4351813b57645
Date: 2022-06-14T00:52:49.854Z
VS Code: 1.59.0
Electron: 13.6.6
Chrome: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Linux x64 5.13.4-051304-generic
  • OS Version:
NAME="Ubuntu"
VERSION="20.04.4 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.4 LTS"
VERSION_ID="20.04"
KERNEL=5.13.4-051304-generic

Steps to Reproduce:

  1. Right click on a Database Project
  2. Select “Schema Compare” from dropdown menu.
  3. In the open Schema Compare menu select a SQL Database as the source and Database Project as the Target
  4. Observe that views and stored procedures appear with ‘Change’ in the Action column but the ‘Compare Details’ window below shows no material difference.

image

Could this be a line ending issue where procedures with CRLF line endings in the database compared the LF characters in the sqlproj files?

Does this issue occur when all extensions are disabled?: No - requires Databse Project Extension for Schema Compare

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (7 by maintainers)

Most upvoted comments

Thanks for chatting this morning, @sgarwood! That was very helpful. For everyone else following along, we think this bug is stemming from the newline characters (LF vs CRLF) in string literals. If a stored procedure (or anything else) is defined involving a multi-line string, the newlines in that string are not ignored by the Ignore Whitespace option… which makes sense because DacFx (the library that powers all these schema operations, like Schema Compare and projects) doesn’t want to try to interpret when it’s okay to convert a character inside of a user-defined string. Tracking down the chain of custody for a string (and therefore its newline characters) across an entire environment/flow can be tricky, 'cause it seems everyone along the way - SQL, Git, SSDT, ADS, Ubuntu, and Windows - all have opinions on what the newline should be and whether to convert it.

Given that, I think we have some options:

  1. Introduce a new option to ignore white space in string literals, separate from Ignore Whitespace that already exists.
  2. Enable whitespace visibility in the diff view (though this may land at VS Code’s feet, as the diff view is upstream from ADS)
  3. Document this behavior so that users can ensure their line endings are all the same.

Any other options I’ve missed? Any feedback on the ones I’ve listed?

Hi @Benjin. Thanks for your efforts on this. I’ve only just had chance to attempt to recreate this from scratch. Following a very similar methodology to what you described above I am also unable to recreate this.

The project I am currently working on was an existing database that I have imported into SSDT but yet to rerun the publish on the production database. Would this have any impact do you think?

Thinking about this, perhaps a more accurate workflow would be:

  1. [SSMS, Windows] Create a SQL Server Database and add a stored procedure to the database against a local SQL Server Instance (this is mimicking our production database we haven’t run publish against yet)
  2. [SSDT, Windows] create new SQL project, and import the database + stored procedure into the SQLproject
  3. [SSDT, Windows] Check the project into git repo
  4. [SSDT, Windows] Publish the project to a SQL Server 2019 Docker container
  5. [ADS, Mac/Linux] Clone the repo
  6. [ADS, Mac/Linux] Use Schema Compare to compare the project with the database running on the Docker container/local SQL Server instance

I’ve dropped you an email as well if you’d like to arrange a call/screen share- I am happy to facilitate.