SchemaDropperImpl does not drop constraints with IF EXISTS

Description

Hi,

I'm running tests on Postgres and it seems that dropping constraints do not include IF EXISTS before the constraint name.

E.g. I see similar logs to the one below:

Looking a bit into the code I noticed some problems:

  • Apparently ForeignKey.sqlDropString() that would respect Dialect.supportsIfExistsBeforeConstraintName() (or in fact any other sqlDropString() method) seems to be never called

  • Dialect.supportsIfExistsBeforeConstraintName() doesn't seem to be consistently applied. Constraint actually doesn't check it, ForeignKey does - but yet again: I can't see the call site of any sqlDropString(). StandardForeignKeyExporter.getSqlDropStrings() which is called in the process of dropping the schema doesn't respect those settings as well.

Any help and clarification is appreciated.

Cheers,
Christoph

Environment

None

Activity

Show:
Christoph Dreis
February 5, 2018, 5:46 PM

Hi, . Thanks for taking care of this. Out of interest: Was my observation correct that sqlDropString seems to be unused?

Andrea Boriero
February 6, 2018, 10:41 AM

Hi ,
you are welcome. Thanks for reporting the issue.

About the code, the

was correctly called, but it generated a drop String statement without checking if the dialect supports If Exists before or after the constraint name, if you are interested you can can see the changeshere.

Christoph Dreis
February 6, 2018, 6:45 PM

Hi,

Sorry, I apparently haven't been clear enough in the comment. I already looked at your change prior to my first comment. (And it basically contains what I basically reported for the StandardForeignKeyExporter myself )

I was asking if ForeignKey.sqlDropString() or alike are called somewhere. (See my first bullet-point from the ticket description). If not, one could think of removing it for maintainability purposes in a follow-up ticket (At the very least it is quite confusing to keep it around if no-one uses it).

Andrea Boriero
February 7, 2018, 5:18 PM

Hi ,

you are right, the method is not used anymore, it will be deprecated in 6.0 and then removed, what we can consider is to deprecate it in 5.3 and then remove in the 6.0 release.

Assignee

Andrea Boriero

Reporter

Christoph Dreis

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure