Created
February 20, 2015 04:03
-
-
Save causal-agent/a416df496bfb41259c86 to your computer and use it in GitHub Desktop.
Postgres dump view defined with VALUES drops column names (PostgreSQL 9.4.1 on Mac OS X 10.10.1 installed via Homebrew)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -v | |
dropdb --if-exists repro | |
dropdb --if-exists repro-restore | |
createdb repro | |
createdb repro-restore | |
# Create a view with named columns defined with VALUES | |
psql repro -c "CREATE VIEW repro_view (my_column) AS VALUES (1);" | |
# Shows "my_column" | |
psql repro -c "SELECT * FROM repro_view;" | |
# Dumped CREATE VIEW statement is missing column names | |
pg_dump repro -t repro_view | |
# Restore dump to a new database | |
pg_dump repro | psql -X repro-restore | |
# Shows "column1" | |
psql repro-restore -c "SELECT * FROM repro_view;" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment