yaegassy / coc-sqlfluff

SQLFluff (A SQL linter and auto-formatter for Humans) extension for coc.nvim
https://www.npmjs.com/package/coc-sqlfluff
MIT License
28 stars 1 forks source link

Difference in behavior between sqlfluff.fix versus running fix on the command line #7

Closed jjjchens235 closed 3 years ago

jjjchens235 commented 3 years ago

Take this SQL code

SELECT CountryId
      ,Country
FROM dbo.DimCountry dc
WHERE dc.RecordUpdateStamp >= DATE_TRUNC('DAY', DATEADD(D, -1, GETDATE()) ); 

If you run :CocCommand sqlfluff.fix none of the issues are fixed. However, if you run this on the command line sqlfluff fix test_file.sql --force and then open the file, the errors are fixed.

:CocCommand sqlfluff.fix works however, if you update the code to any of the following variations prior to running it:

SELECT CountryId
      ,Country
FROM DimCountry dc
WHERE dc.RecordUpdateStamp >= DATE_TRUNC('DAY', DATEADD(D, -1, GETDATE()) );
SELECT CountryId
      ,Country
FROM dbo.DimCountry dc
WHERE dc.RecordUpdateStamp 
>= DATE_TRUNC('DAY', DATEADD(D, -1, GETDATE()) );
yaegassy commented 3 years ago

I tried it in my environment, but could not reproduce the problem. :(

https://user-images.githubusercontent.com/188642/133816145-053f7be8-3b2a-4609-9120-a8ee58e2f680.mp4

jjjchens235 commented 3 years ago

Thanks for sharing this video, the side by side was really neat. I'm not sure why mine isn't working, but my workaround of targeting only specific rules should do for now, ie :CocCommand sqlfluff.fix --rules L011,L012

Thanks again for looking into this.