Skip to content
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

chore(indexer/postgres): update to changes on main #21077

Merged
merged 2 commits into from
Jul 25, 2024

Conversation

aaronc
Copy link
Member

@aaronc aaronc commented Jul 25, 2024

Description

This PR updates cosmossdk.io/postgres/indexer to the latest changes to cosmossdk.io/schema on main. I'm using a replace for now and holding off tagging schema 0.2.0 for a bit. A bit of code deletion was possible with this update.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • New Features

    • Enhanced handling of enum types for improved clarity and alignment with updated schema.
    • Introduced robust error handling during schema initialization.
  • Bug Fixes

    • Addressed potential issues in enum type management and object table creation with refined error handling.
  • Chores

    • Updated local dependency management to facilitate development and testing by redirecting to local schema packages.

Copy link
Contributor

coderabbitai bot commented Jul 25, 2024

Walkthrough

Walkthrough

This update refines the handling of enum types and address kinds across various components of the indexer module. Key changes include transitioning from EnumDefinition to EnumType, improving clarity and type safety, and modifying the schema initialization process for robustness. Additionally, the dependency management for the schema package has been adapted to facilitate local development. These adjustments enhance the overall structure and maintainability of the codebase.

Changes

Files Change Summary
indexer/postgres/column.go Updated enum type handling from EnumDefinition to EnumType in column definitions; renamed Bech32AddressKind to AddressKind.
indexer/postgres/enum.go Altered parameter types in CreateEnumType and related functions from EnumDefinition to EnumType; removed createEnumTypesForFields.
indexer/postgres/go.mod Added a replace directive to use a local schema package for development.
indexer/postgres/internal/testdata/example_schema.go Modified schema definitions to use EnumType; improved initialization with mustModuleSchema.
indexer/postgres/module.go Changed definedEnums from map[string]schema.EnumDefinition to map[string]schema.EnumType; refactored schema initialization.
indexer/postgres/tests/go.mod Updated go.mod to redirect cosmossdk.io/schema to a local path for testing.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ModuleIndexer
    participant Database

    User->>ModuleIndexer: Request to create enum type
    ModuleIndexer->>Database: Create Enum Type
    Database-->>ModuleIndexer: Return success
    ModuleIndexer-->>User: Confirm creation
Loading

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @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.

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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

@aaronc aaronc marked this pull request as ready for review July 25, 2024 16:13
@aaronc aaronc requested a review from a team as a code owner July 25, 2024 16:13
@aaronc aaronc changed the title refactor(indexer/postgres): update to changes on main chore(indexer/postgres): update to changes on main Jul 25, 2024
Copy link
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

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 683371f and 0bdc2e4.

Files ignored due to path filters (2)
  • indexer/postgres/go.sum is excluded by !**/*.sum
  • indexer/postgres/tests/go.sum is excluded by !**/*.sum
Files selected for processing (6)
  • indexer/postgres/column.go (2 hunks)
  • indexer/postgres/enum.go (3 hunks)
  • indexer/postgres/go.mod (1 hunks)
  • indexer/postgres/internal/testdata/example_schema.go (4 hunks)
  • indexer/postgres/module.go (2 hunks)
  • indexer/postgres/tests/go.mod (1 hunks)
Additional context used
Path-based instructions (4)
indexer/postgres/module.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

indexer/postgres/enum.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

indexer/postgres/internal/testdata/example_schema.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

indexer/postgres/column.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

Additional comments not posted (14)
indexer/postgres/go.mod (1)

12-13: LGTM! The replace directive is appropriate for local development.

The addition of the replace directive helps in utilizing a local version of the schema package, which is beneficial for development and testing.

indexer/postgres/tests/go.mod (1)

33-34: LGTM! The replace directive is appropriate for local development.

The addition of the replace directive helps in utilizing a local version of the schema package, which is beneficial for development and testing.

indexer/postgres/module.go (3)

15-15: LGTM! The type change for definedEnums improves type safety.

Changing the type from map[string]schema.EnumDefinition to map[string]schema.EnumType aligns with the updated schema package and enhances type safety.


24-25: LGTM! The initialization of definedEnums is correct.

The NewModuleIndexer method correctly initializes the definedEnums field with the new type map[string]schema.EnumType.


33-53: LGTM! The refactoring improves readability and maintainability.

The InitializeSchema method has been refactored to use a callback function for creating enum types and tables. This change enhances code readability and maintainability. The error handling adjustments ensure proper error capture.

However, ensure the callback functions are correctly implemented and tested.

Verification successful

Verification Successful: Callback functions are correctly implemented and tested.

The functions EnumTypes and ObjectTypes are defined in schema/module_schema.go and have corresponding test cases in schema/module_schema_test.go. This confirms that the callback functions used in the InitializeSchema method are correctly implemented and tested.

  • schema/module_schema.go: func (s ModuleSchema) EnumTypes(f func(EnumType) bool)
  • schema/module_schema.go: func (s ModuleSchema) ObjectTypes(f func(ObjectType) bool)
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation and usage of callback functions in InitializeSchema.

# Test: Search for callback function implementations. Expect: Correct usage in schema package.
rg --type go -A 5 'func \(.*schema\) EnumTypes\('
rg --type go -A 5 'func \(.*schema\) ObjectTypes\('

Length of output: 105


Script:

#!/bin/bash
# Description: Verify the implementation and usage of callback functions in InitializeSchema.

# Test: Search for the implementation of the EnumTypes function within the schema package.
rg --type go 'func \(.*schema\) EnumTypes\('

# Test: Search for the implementation of the ObjectTypes function within the schema package.
rg --type go 'func \(.*schema\) ObjectTypes\('

Length of output: 95


Script:

#!/bin/bash
# Description: Verify the implementation and usage of callback functions in InitializeSchema.

# Test: Search for any function definitions related to EnumTypes within the entire codebase.
rg --type go 'EnumTypes'

# Test: Search for any function definitions related to ObjectTypes within the entire codebase.
rg --type go 'ObjectTypes'

Length of output: 1086

indexer/postgres/enum.go (3)

Line range hint 42-56:
LGTM! But verify the usage of schema.EnumType in the codebase.

The code changes are approved.

However, ensure that all references to schema.EnumType are consistent across the codebase.

Verification successful

Verification successful: Consistent usage of schema.EnumType across the codebase.

The usage of schema.EnumType has been verified and found to be consistent in the following files:

  • indexer/postgres/module.go
  • indexer/postgres/enum.go
  • indexer/postgres/internal/testdata/example_schema.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to `schema.EnumType` in the codebase.

# Test: Search for the usage of `schema.EnumType`. Expect: Consistent usage across the codebase.
rg --type go -A 5 $'schema.EnumType'

Length of output: 2897


Line range hint 14-35:
LGTM! But verify the usage of schema.EnumType in the codebase.

The code changes are approved.

However, ensure that all references to schema.EnumType are consistent across the codebase.

Verification successful

The usage of schema.EnumType is consistent across the codebase.

The references to schema.EnumType in the indexer/postgres directory are correctly implemented.

  • indexer/postgres/module.go
  • indexer/postgres/enum.go
  • indexer/postgres/internal/testdata/example_schema.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to `schema.EnumType` in the codebase.

# Test: Search for the usage of `schema.EnumType`. Expect: Consistent usage across the codebase.
rg --type go -A 5 $'schema.EnumType'

Length of output: 2897


66-68: LGTM! But verify the usage of schema.EnumType in the codebase.

The code changes are approved.

However, ensure that all references to schema.EnumType are consistent across the codebase.

Verification successful

The usage of schema.EnumType is consistent across the codebase.

The code changes are verified and approved.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to `schema.EnumType` in the codebase.

# Test: Search for the usage of `schema.EnumType`. Expect: Consistent usage across the codebase.
rg --type go -A 5 $'schema.EnumType'

Length of output: 2897

indexer/postgres/internal/testdata/example_schema.go (4)

39-44: Enhanced error handling in ExampleSchema initialization.

The change enhances error handling by ensuring that any errors during the creation process will result in a panic.


32-32: LGTM! But verify the usage of field.EnumType in the codebase.

The code changes are approved.

However, ensure that all references to field.EnumType are consistent across the codebase.


83-90: LGTM! But verify the usage of field.EnumType and schema.AddressKind in the codebase.

The code changes are approved.

However, ensure that all references to field.EnumType and schema.AddressKind are consistent across the codebase.

Verification successful

LGTM! The usage of field.EnumType and schema.AddressKind is consistent across the codebase.

The code changes are approved.

  • field.EnumType references:
    • schema/module_schema.go
    • indexer/postgres/column.go
    • indexer/postgres/internal/testdata/example_schema.go
  • schema.AddressKind references:
    • indexer/postgres/column.go
    • indexer/postgres/internal/testdata/example_schema.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to `field.EnumType` and `schema.AddressKind` in the codebase.

# Test: Search for the usage of `field.EnumType` and `schema.AddressKind`. Expect: Consistent usage across the codebase.
rg --type go -A 5 $'field.EnumType'
rg --type go -A 5 $'schema.AddressKind'

Length of output: 1763


67-69: LGTM! But verify the usage of field.EnumType in the codebase.

The code changes are approved.

However, ensure that all references to field.EnumType are consistent across the codebase.

Verification successful

Verified: The usage of field.EnumType is consistent across the codebase.

The instances of field.EnumType in the files schema/module_schema.go, indexer/postgres/column.go, and indexer/postgres/internal/testdata/example_schema.go all align with the intended changes and are used correctly.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to `field.EnumType` in the codebase.

# Test: Search for the usage of `field.EnumType`. Expect: Consistent usage across the codebase.
rg --type go -A 5 $'field.EnumType'

Length of output: 1083


Script:

#!/bin/bash
# Extract more context around the `field.EnumType` usage in the identified files.

# Get additional lines of context for `field.EnumType` in schema/module_schema.go
rg --type go -A 10 -B 10 'field.EnumType' schema/module_schema.go

# Get additional lines of context for `field.EnumType` in indexer/postgres/column.go
rg --type go -A 10 -B 10 'field.EnumType' indexer/postgres/column.go

# Get additional lines of context for `field.EnumType` in indexer/postgres/internal/testdata/example_schema.go
rg --type go -A 10 -B 10 'field.EnumType' indexer/postgres/internal/testdata/example_schema.go

Length of output: 1760

indexer/postgres/column.go (2)

28-28: LGTM! But verify the usage of field.EnumType in the codebase.

The code changes are approved.

However, ensure that all references to field.EnumType are consistent across the codebase.

Verification successful

The usage of field.EnumType is consistent across the codebase.

The references to field.EnumType have been verified and are consistent in the following files:

  • schema/module_schema.go
  • indexer/postgres/column.go
  • indexer/postgres/internal/testdata/example_schema.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to `field.EnumType` in the codebase.

# Test: Search for the usage of `field.EnumType`. Expect: Consistent usage across the codebase.
rg --type go -A 5 $'field.EnumType'

Length of output: 1083


103-103: LGTM! But verify the usage of schema.AddressKind in the codebase.

The code changes are approved.

However, ensure that all references to schema.AddressKind are consistent across the codebase.

Verification successful

The usage of schema.AddressKind is consistent across the codebase, and no instances of schema.Bech32AddressKind were found.

  • indexer/postgres/column.go
  • indexer/postgres/internal/testdata/example_schema.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to `schema.AddressKind` in the codebase.

# Test: Search for the usage of `schema.AddressKind`. Expect: Consistent usage across the codebase.
rg --type go -A 5 $'schema.AddressKind'

Length of output: 679


Script:

#!/bin/bash
# Description: Verify that there are no remaining instances of `schema.Bech32AddressKind` in the codebase.

# Test: Search for the usage of `schema.Bech32AddressKind`. Expect: No occurrences in the codebase.
rg --type go $'schema.Bech32AddressKind'

Length of output: 39

@aaronc aaronc added this pull request to the merge queue Jul 25, 2024
Merged via the queue into main with commit a020729 Jul 25, 2024
76 checks passed
@aaronc aaronc deleted the aaronc/postgres-indexer-update branch July 25, 2024 16:40
alpe added a commit that referenced this pull request Jul 26, 2024
* main:
  feat(log): remove core dependency and update core interface to be dependency free (#21045)
  chore: fix some comments (#21085)
  feat: simulate nested messages (#20291)
  chore(network): remove `DefaultConfigWithAppConfigWithQueryGasLimit` (#21055)
  fix(runtime): remove `appv1alpha1.Config` from runtime (#21042)
  feat(simapp/v2): Add store server to testnet init cmd (#21076)
  chore(indexer/postgres): update to changes on main (#21077)
  feat(schema/appdata): async listener mux'ing (#20879)
  ci: Use large box for 052 branch sims on CI (#21067)
  chore(all): replace all `fmt.Errorf` without paramters with `errors.New` (#21068)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants