Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A tableName """t""" cause error on PostgreSQLSchema.doAllTables() #1106

Closed
lisboa opened this issue Oct 14, 2015 · 1 comment
Closed

A tableName """t""" cause error on PostgreSQLSchema.doAllTables() #1106

lisboa opened this issue Oct 14, 2015 · 1 comment

Comments

@lisboa
Copy link

@lisboa lisboa commented Oct 14, 2015

The test PostgreSQLMigrationMediumTest.view(), used to test quoted table names, fail when try to cleanup the schema. I using the PostgreSQL 9.4.4.

The cause of error is the query used to get all table names. See the line 268 of PostgreSQLSchema:

   "SELECT t.table_name FROM information_schema.tables t" +
    //in this schema
   " WHERE table_schema=?" +
   //that are real tables (as opposed to views)
  " AND table_type='BASE TABLE'" +
  //and are not child tables (= do not inherit from another table).
  " AND NOT (SELECT EXISTS (SELECT inhrelid FROM pg_catalog.pg_inherits" +
  " WHERE inhrelid = ('\"'||t.table_schema||'\".\"'||t.table_name||'\"')::regclass::oid))"  <== erro is here

Instead of

 " WHERE inhrelid = ('\"'||t.table_schema||'\".\"'||t.table_name||'\"')::regclass::oid))"  <== erro is here 

Using the quot_ident function fix the problem, as showed bellow:

" WHERE inhrelid = (quote_ident(t.table_schema)||'.'||quote_ident(t.table_name))::regclass::oid))"

Note: Seem that the function quot_ident exists since PostgreSQL 7.3.

Thanks,
Fabio.

@axelfontaine axelfontaine added this to the Flyway 4.0 milestone Oct 14, 2015
axelfontaine added a commit to flyway/flywaydb.org that referenced this issue Oct 27, 2015
@axelfontaine
Copy link
Contributor

@axelfontaine axelfontaine commented Oct 27, 2015

Thanks! Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.