Skip to content

Just clean up, no changes#609

Merged
DZakh merged 1 commit intomainfrom
dz/jun-clean-up
Jun 20, 2025
Merged

Just clean up, no changes#609
DZakh merged 1 commit intomainfrom
dz/jun-clean-up

Conversation

@DZakh
Copy link
Copy Markdown
Member

@DZakh DZakh commented Jun 19, 2025

Summary by CodeRabbit

  • Refactor

    • Simplified configuration by removing cache storage and schema name parameters from various components.
    • Updated schema handling to require explicit schema arguments where necessary.
    • Streamlined function signatures by removing unused logger parameters.
  • Tests

    • Updated tests to reflect changes in schema and cache storage handling.
    • Removed tests related to deleted PostgreSQL interop functionality.
  • Chores

    • Cleaned up environment variables and internal configuration related to cache schema.

@DZakh DZakh requested a review from JonoPrest June 19, 2025 08:09
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 19, 2025

Walkthrough

This set of changes removes the cacheStorage concept from the persistence layer, eliminates schema name fields from table definitions, and updates all related function signatures and usages. It also deletes the PostgreSQL interoperability module and its associated tests, while refactoring entity history and loading logic to explicitly handle schema names where needed and to simplify function signatures by removing unused logger parameters.

Changes

File(s) Change Summary
codegenerator/cli/npm/envio/src/Persistence.res, codegenerator/cli/templates/static/codegen/src/Config.res, scenarios/test_codegen/test/lib_tests/Persistence_test.res Removed cacheStorage field/parameter from Persistence type and related calls.
codegenerator/cli/npm/envio/src/db/Table.res Removed schemaName from table type and mkTable; deleted PostgresInterop module and related types/functions.
codegenerator/cli/npm/envio/src/db/EntityHistory.res, codegenerator/cli/templates/dynamic/codegen/src/db/Entities.res, codegenerator/cli/templates/static/codegen/src/db/TablesStatic.res, scenarios/test_codegen/test/lib_tests/EntityHistory_test.res Refactored to pass pgSchema explicitly to entity history/table functions; replaced dynamic eval usage; updated schema handling.
codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs, codegenerator/cli/templates/static/codegen/src/LoadLayer.res, codegenerator/cli/templates/static/codegen/src/LoadLayer.resi, scenarios/test_codegen/test/helpers/Mock.res Removed optional ~logger parameter from entity loading functions and their signatures.
codegenerator/cli/templates/static/codegen/src/Env.res Removed cacheSchema environment variable and related configuration.
scenarios/test_codegen/test/lib_tests/Table_test.res Deleted all tests for PostgreSQL interoperability and batch SQL generation for tables.

Sequence Diagram(s)

sequenceDiagram
    participant App
    participant Persistence
    participant PgStorage
    participant EntityHistory

    App->>Persistence: make()
    Note right of Persistence: No cacheStorage used
    App->>PgStorage: setOrThrow(sql, items, ~pgSchema, ~table, ~itemSchema)
    App->>EntityHistory: fromTable(table, ~pgSchema, ~schema)
Loading

Possibly related PRs

Poem

A bunny hopped through fields of code,
Sweeping caches from its load.
Schemas now are crystal clear,
No more logger whispers here!
With tables trimmed and storage neat,
This change is tidy, swift, and sweet.
🐇✨


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
codegenerator/cli/templates/static/codegen/src/LoadLayer.res (1)

57-57: Fix typo in comment.

There's a typo in the comment: "registerign" should be "registering".

-    // Since LoadManager.call prevents registerign entities already existing in the inMemoryStore,
+    // Since LoadManager.call prevents registering entities already existing in the inMemoryStore,
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4f1c18a and 3dd0893.

📒 Files selected for processing (14)
  • codegenerator/cli/npm/envio/src/Persistence.res (0 hunks)
  • codegenerator/cli/npm/envio/src/db/EntityHistory.res (3 hunks)
  • codegenerator/cli/npm/envio/src/db/Table.res (1 hunks)
  • codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs (1 hunks)
  • codegenerator/cli/templates/dynamic/codegen/src/db/Entities.res.hbs (1 hunks)
  • codegenerator/cli/templates/static/codegen/src/Config.res (0 hunks)
  • codegenerator/cli/templates/static/codegen/src/Env.res (0 hunks)
  • codegenerator/cli/templates/static/codegen/src/LoadLayer.res (2 hunks)
  • codegenerator/cli/templates/static/codegen/src/LoadLayer.resi (0 hunks)
  • codegenerator/cli/templates/static/codegen/src/db/TablesStatic.res (2 hunks)
  • scenarios/test_codegen/test/helpers/Mock.res (1 hunks)
  • scenarios/test_codegen/test/lib_tests/EntityHistory_test.res (1 hunks)
  • scenarios/test_codegen/test/lib_tests/Persistence_test.res (0 hunks)
  • scenarios/test_codegen/test/lib_tests/Table_test.res (0 hunks)
💤 Files with no reviewable changes (6)
  • codegenerator/cli/templates/static/codegen/src/Env.res
  • codegenerator/cli/templates/static/codegen/src/LoadLayer.resi
  • codegenerator/cli/templates/static/codegen/src/Config.res
  • codegenerator/cli/npm/envio/src/Persistence.res
  • scenarios/test_codegen/test/lib_tests/Table_test.res
  • scenarios/test_codegen/test/lib_tests/Persistence_test.res
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build_and_test
🔇 Additional comments (14)
codegenerator/cli/templates/dynamic/codegen/src/db/Entities.res.hbs (1)

107-107: LGTM! Clean refactoring to explicit schema handling.

The change to pass ~pgSchema=Env.Db.publicSchema explicitly to EntityHistory.fromTable is a good improvement over embedding schema names in table definitions. This provides better separation of concerns and more explicit control over schema specification.

scenarios/test_codegen/test/helpers/Mock.res (1)

57-57: Good simplification by removing unused logger parameter.

Removing the ~logger parameter from the loadEntitiesByIds function signature cleans up the interface by eliminating an unused parameter. This aligns with the broader cleanup effort across the codebase.

codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs (1)

266-266: Consistent parameter cleanup improves interface design.

The removal of the ~logger parameter from makeLoadEntitiesByIds is consistent with similar changes across the codebase. This simplifies the function signature while maintaining all necessary functionality.

codegenerator/cli/npm/envio/src/db/Table.res (1)

90-100: Verify consistency between PR objectives and actual changes.

The removal of the schemaName field from the table type and the ~schemaName parameter from mkTable represents a significant structural change to the table definition system. However, the PR title indicates "Just clean up, no changes" which seems inconsistent with these substantial modifications.

Please verify that this breaking change aligns with the intended scope of this PR. The changes appear to be part of a larger refactoring to handle PostgreSQL schema names explicitly rather than embedding them in table definitions.

#!/bin/bash
# Description: Check for any remaining usage of schemaName in table-related code
# Expected: No remaining references to table.schemaName or ~schemaName parameters

echo "Searching for remaining schemaName references in table-related files..."
rg -A 3 -B 3 "schemaName" --type rescript

echo "Searching for mkTable calls that might still use schemaName..."
rg -A 5 "mkTable\(" --type rescript

Likely an incorrect or invalid review comment.

codegenerator/cli/templates/static/codegen/src/db/TablesStatic.res (2)

42-42: Good explicit schema reference in SQL query.

Replacing the implicit table.schemaName reference with explicit Env.Db.publicSchema in the SQL query makes the schema source more transparent and aligns with the broader refactoring to remove schema names from table definitions.


245-245: Consistent with schema handling refactoring.

The explicit ~pgSchema=Env.Db.publicSchema parameter to EntityHistory.fromTable follows the same pattern established in the dynamic templates, providing consistent schema handling across the codebase.

codegenerator/cli/templates/static/codegen/src/LoadLayer.res (2)

35-40: LGTM: Logger parameter removal is clean.

The removal of the optional ~logger parameter from the loadEntitiesByIds function signature is consistent and simplifies the interface appropriately.


60-60: LGTM: Function call updated correctly.

The call to loadEntitiesByIds correctly reflects the updated function signature without the ~logger parameter.

codegenerator/cli/npm/envio/src/db/EntityHistory.res (4)

178-178: LGTM: Explicit schema parameter improves clarity.

Making the PostgreSQL schema an explicit parameter instead of relying on table.schemaName improves the function's interface clarity and makes schema handling more explicit.


253-254: LGTM: Consistent use of explicit schema parameter.

The schema-qualified table paths correctly use the explicit pgSchema parameter, ensuring consistent schema handling throughout the function.


176-176: ```shell
#!/bin/bash

Refined search for literal eval( call sites in ReScript files

rg -n --fixed-strings "eval(" --glob "*.res"


---

`337-337`: ```shell
#!/bin/bash
# Display the full insertFnString definition to verify any dynamic content
sed -n '320,360p' codegenerator/cli/npm/envio/src/db/EntityHistory.res
scenarios/test_codegen/test/lib_tests/EntityHistory_test.res (2)

55-55: LGTM: Test updated for explicit schema parameter.

The test correctly passes the explicit pgSchema="public" parameter to match the updated EntityHistory.fromTable function signature.


63-70: LGTM: Custom batch set function replaces removed utility.

The custom batchSetMockEntity function appropriately replaces the removed Table.PostgresInterop.makeBatchSetFn by directly calling PgStorage.setOrThrow with the necessary parameters including the explicit pgSchema.


let insertFn: (Postgres.sql, Js.Json.t, ~shouldCopyCurrentEntity: bool) => promise<unit> =
insertFnString->Table.PostgresInterop.eval
insertFnString->eval
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@DZakh, I can't remember when this was added but don't you think eval should be at start up time and not at runtime of the insert function?

//We need to update values here not delet the rows, since restarting without a row
//has a different behaviour to restarting with an initialised row with zero values
let resetCurrentCurrentSyncStateQuery = `UPDATE ${table.schemaName}.${table.tableName}
let resetCurrentCurrentSyncStateQuery = `UPDATE "${Env.Db.publicSchema}"."${table.tableName}"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why make this change? I don't mind either way, and I see this file used to access the env anyhow, but it seems counter productive for librifying if we remove thes from the state/config of the table. I personally think ultimately the whole system should run off of a config outside of the environment and the generated registeration can apply the environment variables.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think I see the point in that, the PgStorage module is what accepts the public schema not at the table level. I wonder if this then shouldn't be moved to the PgStorage module.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes. We should move it there at some point. Table shouldn't know anything about postgres implementation.

Comment on lines -43 to -50
let expected = `(sql, rows) => {
return sql\`
INSERT INTO "custom"."test_table"
\${sql(rows, "id", "field_a")}
ON CONFLICT(id) DO UPDATE
SET
"id" = EXCLUDED."id", "field_a" = EXCLUDED."field_a";\`
}`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do these kinds of tests still exist somewhere else? I think I remember you made a new test suite for it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, there are new tests. Also, it's weird to test code, which is not used :)

Copy link
Copy Markdown
Collaborator

@JonoPrest JonoPrest left a comment

Choose a reason for hiding this comment

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

Cool nothing blocking! Thanks @DZakh

@DZakh DZakh merged commit d39c4f1 into main Jun 20, 2025
2 checks passed
@DZakh DZakh deleted the dz/jun-clean-up branch June 20, 2025 08:06
@coderabbitai coderabbitai Bot mentioned this pull request Sep 11, 2025
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