Add view and materialized view support (PlantUML)#53
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
Adds support for SQL views and materialized views throughout the loader, schema structures, tests, and both PlantUML and Mermaid generators.
- Extend
SqlERDataandsql_entitieswith a newViewtype and aviewsfield. - Update the PostgreSQL ERD loader to fetch and classify both standard and materialized views.
- Enhance PlantUML and Mermaid generators (and tests) to render views; bump version to 0.6.0.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_db.sql | Added CREATE VIEW and CREATE MATERIALIZED VIEW DDL. |
| tests/sql_loader_test.rs | New views() async test validating both view types. |
| src/sql_entities.rs | Introduced View struct and views in SqlERData. |
| src/psql_erd_loader.rs | Loader now queries and separates views and matviews. |
| src/plantuml_generator.rs | Templates and rendering logic updated for views. |
| src/mermaid_generator.rs | ViewGenerator impl updated; minor template trim tweak. |
| docker-compose.yml | Upgraded Postgres image to postgres:17.4. |
| README.md | Updated example PlantUML link. |
| Cargo.toml | Bumped version from 0.5.0 to 0.6.0. |
Comments suppressed due to low confidence (1)
src/psql_erd_loader.rs:452
- Materialized views are also returned by the
VIEWtype query and then added again afterpg_matviews, which will duplicate entries. Filter out materialized views from this branch (e.g. by checking against your mat_views list) to avoid duplicates.
TableType::View => {
Comment on lines
+424
to
+429
| // Collect table names and types as a vector of tuples | ||
| let table_names_with_types: Vec<(String, TableType)> = res | ||
| .iter() | ||
| .map(|row| (row.get("table_name"), row.get("table_type"))) | ||
| .collect(); | ||
|
|
There was a problem hiding this comment.
This block re-collects table_names_with_types but it was already built earlier—consider reusing the initial vector instead of duplicating the query for clarity and reduced overhead.
Suggested change
| // Collect table names and types as a vector of tuples | |
| let table_names_with_types: Vec<(String, TableType)> = res | |
| .iter() | |
| .map(|row| (row.get("table_name"), row.get("table_type"))) | |
| .collect(); | |
| // Reuse the previously collected table_names_with_types vector |
| #[derive(Serialize)] | ||
| struct SPuml { | ||
| puml_lib: String, | ||
| // entities can be renamed to "tables" |
There was a problem hiding this comment.
[nitpick] This placeholder comment appears to be a leftover note. Consider removing or clarifying it to keep comments directly relevant.
Suggested change
| // entities can be renamed to "tables" | |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#13