-
Notifications
You must be signed in to change notification settings - Fork 156
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
Bug fixes for views: return views in get_table_options and improve reflection #46
Conversation
Since there's little distinction between tables and views, this PR also includes a refactor to reduce duplication of code between table-specific and view-specific methods. |
@graingert @bouk @cpcloud Thoughts? |
@@ -643,7 +623,8 @@ def _get_all_table_and_view_info(self, connection, **kw): | |||
AS "diststyle", | |||
c.relowner AS "owner_id", | |||
u.usename AS "owner_name", | |||
pg_get_viewdef(c.oid) AS "view_definition", | |||
TRIM(TRAILING ';' FROM pg_catalog.pg_get_viewdef(c.oid, true)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this trim for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output of pg_get_viewdef
includes a semicolon at the end of the query. The SQLAlchemy CreateTable
, etc. commands don't include a semicolon at the end of the output, so we need to strip that out somewhere for consistency.
This TRIM(TRAILING ';'
is the solution used in psql's \d+
command to get rid of the semicolon.
This doesn't change functionality at all right? |
With this change, Both of the previous behaviors I consider bugs. |
Can you add tests and changelog for these bugs please? |
I'm going to need some help if we're going to try to add tests for these. The current test structure for reflection relies on @graingert - Do you have suggestions about how we can create a view in our test models to reflect from? |
One option is to use the
|
Test failure is an unexpected 500 from bigcrunch again. |
For now you'll have to retry the build after redshift has booted up properly
|
.compile(engine)) | ||
|
||
|
||
def test_view_reflection(redshift_engine): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
8bfbfea
to
ccb1abd
Compare
Totally forgot about the changelog. I just pushed an update that adds a note about the changes. |
@@ -29,6 +30,7 @@ | |||
- Raise ``NoSuchTableError`` when trying to reflect a table that doesn't exist. | |||
(`Issue #38 <https://github.com/graingert/redshift_sqlalchemy/issues/38>`_) | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file is auto-generated by zest.releaser do we need this extra new-line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The newline as an attempt to make the whitespacing consistent. Other sections in this file are preceeded by two blank lines. It looks like I missed adding an extra blank line beneath the 0.2.1 section while I was at it.
It doesn't matter functionally, so I'll revert the change to avoid noise in the diff.
43e8362
to
ad64806
Compare
We're still getting intermittent 500 responses from bigcrunch. How well do you understand the behavior, @graingert? |
@jklukas there's a small window between the cluster booting and cluster being available (DNS etc) where these 500s occur. I know how to fix this. Are you able to access the rebuild button on Travis? |
I have limited experience with Travis, so didn't know to look for one. I was just able to trigger a rebuild. We'll see how it does. |
This looks great, merging. Thanks very much! |
Bug fixes for views: return views in get_table_options and improve reflection
Because SQLAlchemy only has limited support for views, some methods that include
table
in the name are also supposed to return views.