Skip to content

Add view and materialized view support (PlantUML)#53

Merged
kurotych merged 10 commits intomainfrom
view-support
May 17, 2025
Merged

Add view and materialized view support (PlantUML)#53
kurotych merged 10 commits intomainfrom
view-support

Conversation

@kurotych
Copy link
Copy Markdown
Owner

@kurotych kurotych commented May 12, 2025

#13

image

@kurotych kurotych changed the title Add views to test_db Add view and materialized view support May 15, 2025
@kurotych kurotych changed the title Add view and materialized view support Add view and materialized view support (PlantUML) May 15, 2025
@kurotych kurotych marked this pull request as ready for review May 17, 2025 10:33
@kurotych kurotych requested a review from Copilot May 17, 2025 10:33
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds support for SQL views and materialized views throughout the loader, schema structures, tests, and both PlantUML and Mermaid generators.

  • Extend SqlERData and sql_entities with a new View type and a views field.
  • 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 VIEW type query and then added again after pg_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();

Copy link

Copilot AI May 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copilot uses AI. Check for mistakes.
#[derive(Serialize)]
struct SPuml {
puml_lib: String,
// entities can be renamed to "tables"
Copy link

Copilot AI May 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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"

Copilot uses AI. Check for mistakes.
@kurotych kurotych merged commit 812c0d0 into main May 17, 2025
3 checks passed
@kurotych kurotych deleted the view-support branch October 12, 2025 09:28
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.

2 participants