Skip to content

Conversation

@taka-oyama
Copy link
Collaborator

@taka-oyama taka-oyama commented May 9, 2025

The following is in this fix.

  • added missing generation field.
  • matched styling with other metadata getter methods.

Summary by CodeRabbit

  • Bug Fixes
    • Improved accuracy of column metadata, including handling of nullable columns, default values, and auto-increment detection.
  • Tests
    • Expanded test coverage to verify column details for nullable columns, columns with default values, and auto-increment columns.

@taka-oyama taka-oyama requested a review from a team May 9, 2025 07:29
@taka-oyama taka-oyama self-assigned this May 9, 2025
@taka-oyama taka-oyama added bug Something isn't working waiting for review labels May 9, 2025
@coderabbitai
Copy link

coderabbitai bot commented May 9, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

"""

Walkthrough

The updates refine column metadata handling by improving type annotations and field access in the Processor class, revising the SQL query in the Grammar class to select more specific fields, and expanding schema builder tests to cover nullable, default, and auto-increment column scenarios with more precise assertions.

Changes

Files/Groups Change Summary
src/Query/Processor.php Updated processColumns method with more precise parameter and return types, switched to property-style access, changed key names to lowercase, added a generation field, and revised logic for nullable and default fields.
src/Schema/Grammar.php Replaced the compileColumns method implementation to select specific columns from information_schema.columns, removed the table_schema filter, and used quoted table names.
tests/Schema/BuilderTestLast.php Renamed test_getColumns to test_getColumns_with_nullable, updated its logic, and added two new tests: test_getColumns_with_default and test_getColumns_with_auto_increment to verify handling of column metadata for nullable, default, and auto-increment columns.

Suggested labels

enhancement

Suggested reviewers

  • kt81
    """

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.

@taka-oyama taka-oyama changed the title Fix/get columns data fix: SchemaBuilder::getColumns was missing values May 9, 2025
Copy link

@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: 2

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between bd0adbe and 3429db7.

📒 Files selected for processing (3)
  • src/Query/Processor.php (1 hunks)
  • src/Schema/Grammar.php (1 hunks)
  • tests/Schema/BuilderTestLast.php (1 hunks)
🔇 Additional comments (4)
src/Schema/Grammar.php (1)

52-71: Query improvements enhance column metadata retrieval.

The rewritten compileColumns method now explicitly selects specific column attributes (name, type, nullable, default) and provides them with consistent lowercase aliases. This makes the column metadata retrieval more precise and aligns with the updated processColumns method in the Processor class.

The table filtering was also improved by removing the empty table_schema filter, which might have been limiting the results. The use of implode for constructing the query parts enhances readability.

src/Query/Processor.php (1)

76-77: Improved type annotations for better code documentation.

The parameter and return type annotations now use more specific types, providing better documentation and type safety when working with the column metadata.

tests/Schema/BuilderTestLast.php (2)

225-246: Improved test with more specific assertions for nullable columns.

The test was renamed to clarify its purpose and now includes more detailed assertions to verify the correct handling of a nullable integer primary key column. The test ensures that all required column properties are properly populated in the metadata.


248-269: Added test coverage for columns with default values.

This new test ensures that default values are correctly captured and processed in the column metadata, particularly for string columns with default values. The assertions verify that the type, nullability, and default value are all correctly represented.

Copy link

@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: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3429db7 and 0b48db6.

📒 Files selected for processing (3)
  • src/Query/Processor.php (1 hunks)
  • src/Schema/Grammar.php (1 hunks)
  • tests/Schema/BuilderTestLast.php (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/Schema/BuilderTestLast.php
  • src/Query/Processor.php
🧰 Additional context used
🪛 PHPStan (2.0.3)
src/Schema/Grammar.php

59-59: Method Colopl\Spanner\Schema\Grammar::compileColumns() overrides method Illuminate\Database\Schema\Grammars\Grammar::compileColumns() but misses parameter #2 $table.

(parameter.missing)

@taka-oyama taka-oyama changed the base branch from master to 8.x May 9, 2025 07:38
@taka-oyama taka-oyama force-pushed the fix/get-columns-data branch from 0b48db6 to ba405d0 Compare May 9, 2025 07:38
@taka-oyama taka-oyama requested a review from halnique May 15, 2025 03:31
@taka-oyama taka-oyama requested a review from halnique May 15, 2025 06:28
Copy link
Contributor

@halnique halnique left a comment

Choose a reason for hiding this comment

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

LGTM

@taka-oyama taka-oyama merged commit 4d4d710 into 8.x May 16, 2025
1 check passed
@taka-oyama taka-oyama deleted the fix/get-columns-data branch May 16, 2025 07:54
taka-oyama added a commit that referenced this pull request May 21, 2025
* fix!: SchemaBuilder::getForeignKeys was returning incorrect values (#275)

* fix!: SchemaBuilder::getTables was returning incorrect values (#278)

* fix: SchemaBuilder::getColumns was missing values (#280)

Co-authored-by: halnique <[email protected]>

* fix: phpstan errors

* fix

---------

Co-authored-by: halnique <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working waiting for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants