martinjw / dbschemareader

Read database metadata (from SqlServer/Oracle/MySql/SQLite/PostgreSql/DB2 etc) into one simple model
Microsoft Public License
293 stars 128 forks source link

PostgreSql names being quoted even when EscapeNames is set to false #123

Closed r-work closed 3 years ago

r-work commented 3 years ago

When setting EscapeNames to false, some names are still escaped/quoted.

Consider the following code:

var dgf = new DatabaseSchemaReader.SqlGen.DdlGeneratorFactory(SqlType.PostgreSql);
var itg = dgf.TableGenerator(tb);
itg.EscapeNames = false;
var sql = itg.Write();

it comes out something like this:

CREATE TABLE dbo.access_restriction
(
  id  BIGSERIAL,
  type_id BIGINT  NOT NULL
);

CREATE INDEX "access_restriction_type_id_idx" ON "dbo"."access_restriction"("type_id");

COMMENT ON COLUMN dbo.access_restriction."id" IS 'Unique Id for this item';
COMMENT ON COLUMN dbo.access_restriction."type_id" IS 'Type of data to be accessed';
GO

What's wrong? When writing tables it doesn't quote anything (correct). When writing indexes it quotes everything (incorrect). When writing comments it quotes the column name only (incorrect).

Schema is read from SQL server if that means anything.

martinjw commented 3 years ago

Should be fixed in https://github.com/martinjw/dbschemareader/releases/tag/2.7.9.0

r-work commented 3 years ago

Thanks for the quick fix. However, it still quotes column names when writing comments:

COMMENT ON COLUMN dbo.access_restriction."id" IS 'Unique Id for this item';

Also, nuget version is wrong i think. (still says 2.7.8).

martinjw commented 3 years ago

New build: https://github.com/martinjw/dbschemareader/releases/tag/2.7.9.2

r-work commented 3 years ago

Works a expected, thanks for the fix.