LinqConnect Professional Version 4.5.1004 (09-Jun-2016) - Delete database PostgreSql

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
AKRRKA
Posts: 198
Joined: Thu 26 Jan 2012 15:07
Location: Russia
Contact:

LinqConnect Professional Version 4.5.1004 (09-Jun-2016) - Delete database PostgreSql

Post by AKRRKA » Tue 21 Jun 2016 14:56

Does not work the delete database for PostgreSql.
When running DeleteDatabase() command, like this:

Code: Select all

contextForDeleteDatabase.DeleteDatabase(false, true);
generated incorrect code:

Code: Select all

DROP SCHEMA public CASCADE

that's the correct code:

Code: Select all

DROP DATABASE cetest
For information:

Code: Select all

ConnectionString="user id=postgres;password=masterpass;host=10.5.5.1;database=cetest;persist security info=True;unicode=True;schema=public"

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: LinqConnect Professional Version 4.5.1004 (09-Jun-2016) - Delete database PostgreSql

Post by Shalex » Wed 22 Jun 2016 09:23

The correct behaviuor is described in the documentation:
"Creates and executes script that deletes database tables with their constraints, indexes, and foreign keys.
If deleteSchema is set to true, the schema will be deleted.
The database or schema itself is not deleted."

AKRRKA
Posts: 198
Joined: Thu 26 Jan 2012 15:07
Location: Russia
Contact:

Re: LinqConnect Professional Version 4.5.1004 (09-Jun-2016) - Delete database PostgreSql

Post by AKRRKA » Wed 22 Jun 2016 15:14

Do not understand.
1) For MS SQL Server and MySQL when deleting base executed correct command.
2) For PostgreSQL executed an incorrect command.
Is necessary for PostgreSQL do the right commands.
I showed an example of the correct command.

Code: Select all

DROP DATABASE cetest
You want to say that this will not work?

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: LinqConnect Professional Version 4.5.1004 (09-Jun-2016) - Delete database PostgreSql

Post by Shalex » Wed 29 Jun 2016 11:49

If deleteSchema is set to true, the behaviour is the following:
DROP DATABASE is generated for SQL Server
DROP DATABASE is generated for MySQL
DROP SCHEMA is generated for PostgreSQL
DROP USER is generated Oracle
the database file is removed from file system in case of SQLite

The DeleteDatabase(false,true) was designed to remove the smallest "container" of database objects. For PostgreSQL, it is a schema. The behaviour change may lead to the unexpected result (removing database) for other customers, so we preserve current way how it works.

AKRRKA
Posts: 198
Joined: Thu 26 Jan 2012 15:07
Location: Russia
Contact:

Re: LinqConnect Professional Version 4.5.1004 (09-Jun-2016) - Delete database PostgreSql

Post by AKRRKA » Thu 30 Jun 2016 08:56

Well, for "PostgreSql" type I tried that.

Code: Select all

contextForDeleteDatabase.DeleteDatabase(false, false);
But so, too, the database is not removed. Only remove the table. Generated commands like:

Code: Select all

...
DROP TABLE "AddressCities" CASCADE
...
How to remove the database itself?

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: LinqConnect Professional Version 4.5.1004 (09-Jun-2016) - Delete database PostgreSql

Post by Shalex » Fri 01 Jul 2016 17:15

There are two ways to remove database:

1) via ADO.NET connection (PgSqlConnection), connect to other database (e.g., "postgres") and execute cmd.CommandText="drop database cetest"

2) implement your own descendant of a standard PgSqlDataProvider class, override its DeleteDatabase method, and employ your own class instead of a standard PgSqlDataProvider class

Post Reply