Skip to content

427 allows passing schema name in create_view() and create_materialized_view() #597

Open
nestguti wants to merge 5 commits intokvesteri:masterfrom
nestguti:427
Open

427 allows passing schema name in create_view() and create_materialized_view() #597
nestguti wants to merge 5 commits intokvesteri:masterfrom
nestguti:427

Conversation

@nestguti
Copy link
Copy Markdown

Update create_view() and create_materialized_view() functions to pass schema name for Postgres DB

add test unit test_views_schema.py and update test_views.py

@seachad
Copy link
Copy Markdown

seachad commented May 25, 2022

Hi, reviewing the code I wonder if DropView has support for schema as CreateView. Maybe I'm wrong but it appears it doesn't.

@nestguti
Copy link
Copy Markdown
Author

nestguti commented May 25, 2022

Hi, reviewing the code I wonder if DropView has support for schema as CreateView. Maybe I'm wrong but it appears it doesn't.

Yes, It does:

@compiler.compiles(DropView)
def compile_drop_materialized_view(element, compiler, **kw):
    return 'DROP {}VIEW IF EXISTS {} {}'.format(
        'MATERIALIZED ' if element.materialized else '',
        compiler.dialect.identifier_preparer.format_table(element.table, use_schema=True),
        'CASCADE' if element.cascade else ''
    )

@kurtmckee
Copy link
Copy Markdown
Collaborator

@nestguti thanks for pointing that out. I edited your comment so it would show up as highlighted Python. In the future you can use this syntax to accomplish the same thing:

```python
for code in example:
    print("Use three backticks and the name of the language!")
    print("Then end the code block with another three backticks!")
```

@nestguti
Copy link
Copy Markdown
Author

@nestguti thanks for pointing that out. I edited your comment so it would show up as highlighted Python. In the future you can use this syntax to accomplish the same thing:

```python
for code in example:
    print("Use three backticks and the name of the language!")
    print("Then end the code block with another three backticks!")

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants