question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CreateViewGenerator generates incorrect SQL for PostgreSQL

See original GitHub issue

Description CORE-2377 removed the DROP statement generation for PostgreSQL in CreateViewGenerator (commit).

The ticket states that DROP + CREATE can be substituted for a “CREATE OR REPLACE” statement in PostgreSQL in all cases. However, this assumption proved to be incorrect. Quoting PostgreSQL docs for CREATE VIEW:

CREATE OR REPLACE VIEW is similar, but if a view of the same name already exists, it is replaced. The new query must generate the same columns that were generated by the existing view query (that is, the same column names in the same order and with the same data types), but it may add additional columns to the end of the list. The calculations giving rise to the output columns may be completely different.

Changesets that were created for versions < 3.7.0 containing createView are now broken because of this change.

To Reproduce See here: https://github.com/abelk2/liquibase-postgres-createview/blob/master/README.md

Expected behavior For PostgreSQL, createView change withreplaceIfExists = "true" should replace existing database views even when field names / data types are changed just like it did before 3.7.0

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:22 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
rozenshteyncommented, Oct 12, 2022

Thank you for the clarifications @nvoxland ! I have made initial code changes already. Will try to update them based on the feedback and, hopefully, submit them this coming weekend.

1reaction
nvoxlandcommented, Oct 11, 2022

To answer your question on global properties in general, we have ConfigurationDefinitions like get set in SqlConfiguration and GlobalConfiguration which define the global properties. Then you can always get the value in code via something like GlobalConfiguration.LIQUIBASE_CATALOG_NAME.getCurrentValue() and it will get the value however it was set.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Liquibase: CreateViewGenerator generates incorrect SQL for ...
Migration from 1.3 to 2.0 exposes issue with view replacement. Not a dropwizard issue, but creating a placeholder to track and incorporate ...
Read more >
Documentation: 15: CREATE VIEW - PostgreSQL
Description. CREATE VIEW defines a view of a query. The view is not physically materialized. Instead, the query is run every time the...
Read more >
Error on create view with cast numeric as decimal on postgresql
Well, I need to create views where the numeric columns stay rounded 15.3 but I'm encountering a problem I could not understand. The...
Read more >
How to fix a sequence when it goes out of sync in Postgres
When do sequences go out of sync? · importing many rows with an INSERT script or restoring an extensive database; · manually setting...
Read more >
Hibernate with PostgreSQL - 6 things you need to know
Queries: Call PostgreSQL-specific SQL Functions; 6 6. ... The TABLE strategy uses a database table to generate unique primary key values.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found