ErikEJ / SqlCeToolbox

SQLite & SQL Server Compact Toolbox extension for Visual Studio, SSMS (and stand alone)
Other
843 stars 175 forks source link

SQLite views - pretty print #506

Closed mwallnoefer closed 6 years ago

mwallnoefer commented 7 years ago

It would be nice to correctly reproduce the line-feeds when scripting SQL views.

CREATE VIEW [vwGroupBibs] AS      SELECT BibFrom, BibTo, idGroup                      FROM GroupBibs;

should become (like it happens on the tables):

CREATE VIEW [vwGroupBibs] AS
      SELECT BibFrom, BibTo, idGroup
                      FROM GroupBibs;

Steps to reproduce

Script as CREATE on the view's context menu but also in the Script Database commands.

Further technical details

Toolbox version: 4.7.232.0 Database engine: SQlite Visual Studio or SSMS version: Visual Studio 2013

ErikEJ commented 7 years ago

Not sure I understand why you are facing this, I already add newlines !?

https://github.com/ErikEJ/SqlCeToolbox/blob/master/src/API/Generator/Generator.cs#L2137

ErikEJ commented 7 years ago

Ping?

mwallnoefer commented 7 years ago

Ah sorry, forgotten to answer. Yes but in view.Definition, do you handle them also there? According to me this is not the case atm.

ErikEJ commented 7 years ago

I do not do anything with view.Definition, I just display it as is from the SQLite schema info.

ErikEJ commented 7 years ago

Is it a linebreak issue, perhaps?

mwallnoefer commented 7 years ago

This means if I use the sqlite3 tool from cmdline I see the view definition in the exactly same manner? I need to re-try this... With SQLite Personal it is different.

Linebreaks: exactly, it is a problem concerning this (spaces are represented correctly).

ErikEJ commented 7 years ago

Pls try the latest daily and let me know!

mwallnoefer commented 7 years ago

I would give it a look but am unable to do so. In the latest daily build at my SQLite connections disappeared (under Data Connections). When I try to add a new connection, the configuration dialog pops up, but after clicking on Close it does not appear in the tree - this is strange.

grafik

ErikEJ commented 7 years ago

Could you show me the About dialog in the latest build? Sounds like your DataProvider installation is broken.

mwallnoefer commented 7 years ago

grafik

Ah yes. Where do I need to download it?

ErikEJ commented 7 years ago

http://system.data.sqlite.org/downloads/1.0.105.2/sqlite-netFx46-setup-bundle-x86-2015-1.0.105.2.exe from http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki

ErikEJ commented 7 years ago

Guide here: https://github.com/ErikEJ/SqlCeToolbox/wiki/EF6-workflow-with-SQLite-DDEX-provider

mwallnoefer commented 7 years ago

I have tried to follow your instructions but no change in behaviour. But now the SQLite EF6 DBProvider is in the GAC. grafik

mwallnoefer commented 7 years ago

Now I turned back to the latest stable and everything works again (I can see all SQLite DBs).

grafik

ErikEJ commented 7 years ago

Thanks, I will try to reproduce and provide a fix!

ErikEJ commented 7 years ago

Fixed in the latest daily build, thanks for reporting! Could I ask you to try it out an let me know?

mwallnoefer commented 7 years ago

Here my answer:

mwallnoefer commented 7 years ago

sqlite3 output:

sqlite> .dump
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE VIEW [vwBibs] AS
WITH RECURSIVE
    [tab] AS(
        SELECT 1 AS [BibFrom],
               10 AS [BibTo]
        UNION ALL
        SELECT [BibFrom] + 1,
               [BibTo]
        FROM   [tab]
        WHERE  [BibFrom] < [BibTo]
    )
SELECT [BibFrom]
FROM   [tab];
COMMIT;

test.zip

mwallnoefer commented 6 years ago

@ErikEJ, have you managed to figure out something?

ErikEJ commented 6 years ago

Yes, it was an issue with the System.Data.Sqlite implementation of GetSchema("Views") ! This line of code removes any formatting!

          strItem = rd.GetString(4).Replace('\r', ' ').Replace('\n', ' ').Replace('\t', ' ');

Changed to get the raw defintion now - fixed in latest build, please let me know if it works for you.

mwallnoefer commented 6 years ago

It works, wonderful!