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

fix: set column canNull default to false #195

Merged
merged 2 commits into from
Mar 22, 2024
Merged

fix: set column canNull default to false #195

merged 2 commits into from
Mar 22, 2024

Conversation

killagu
Copy link
Contributor

@killagu killagu commented Mar 21, 2024

Checklist
  • npm test passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)
Description of change

Summary by CodeRabbit

  • New Features

    • Enhanced SQL query logging for table creation to aid in debugging.
  • Bug Fixes

    • Adjusted default canNull behavior in column definitions to enhance data integrity.
    • Updated various column definitions to include NOT NULL constraints, ensuring stricter data validation.
  • Refactor

    • Removed unused code and comments to clean up the codebase.
    • Improved flexibility in the data access layer by allowing reassignment of a key property.
  • Tests

    • Added and modified tests to reflect changes in SQL generation logic and column nullability.

Copy link

coderabbitai bot commented Mar 21, 2024

Walkthrough

The updates focus on enhancing data integrity and refining the development process. Adjustments include enforcing non-nullability in column definitions unless specified otherwise, cleaning up code by removing outdated comments, and improving debugging by logging SQL queries. Additionally, modifications in test fixtures and SQL generation logic reflect these stricter data constraints, while a plugin's property has been made mutable for flexible initialization.

Changes

Files Summary
.../model/ColumnModel.ts, .../test/fixtures/modules/dal/Foo.ts, .../test/SqlGenerator.test.ts, .../test/fixtures/modules/generate_codes/dal/structure/Foo.sql, .../test/fixtures/modules/generate_codes/dal/structure/MultiPrimaryKey.sql Adjusted nullability constraints and data types across column definitions.
.../model/TableModel.ts Removed a commented-out TODO.
.../test/DataSource.test.ts Added logging for SQL table creation queries.
plugin/dal/app.ts Made dalTableEggPrototypeHook mutable and moved its instantiation.

🐰✨
In the land of code, where changes abound,
A rabbit hopped, leaving marks profound.
"No more nulls!" it declared with glee,
For data's integrity, as strong as can be.
With every hop, a bug squashed, a feature bright,
In the garden of code, under the moonlight.
🌟🐾

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-tests 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 tests 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 tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

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

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 1c7d145 and 00ec4e3.
Files ignored due to path filters (2)
  • core/dal-runtime/test/fixtures/modules/generate_codes/dal/structure/Foo.json is excluded by: !**/*.json
  • core/dal-runtime/test/fixtures/modules/generate_codes/dal/structure/MultiPrimaryKey.json is excluded by: !**/*.json
Files selected for processing (8)
  • core/dal-decorator/src/model/ColumnModel.ts (1 hunks)
  • core/dal-decorator/src/model/TableModel.ts (1 hunks)
  • core/dal-runtime/test/DataSource.test.ts (1 hunks)
  • core/dal-runtime/test/SqlGenerator.test.ts (1 hunks)
  • core/dal-runtime/test/fixtures/modules/dal/Foo.ts (1 hunks)
  • core/dal-runtime/test/fixtures/modules/generate_codes/dal/structure/Foo.sql (1 hunks)
  • core/dal-runtime/test/fixtures/modules/generate_codes/dal/structure/MultiPrimaryKey.sql (1 hunks)
  • plugin/dal/app.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • core/dal-decorator/src/model/TableModel.ts
Additional comments: 8
core/dal-runtime/test/fixtures/modules/generate_codes/dal/structure/MultiPrimaryKey.sql (1)
  • 4-4: The change to make the name column NOT NULL aligns with the PR's objective to enhance data integrity by enforcing non-nullability by default. This is a good practice, especially for a column that is also a UNIQUE KEY.
plugin/dal/app.ts (2)
  • 10-10: Removing the readonly modifier from dalTableEggPrototypeHook and moving its instantiation to configWillLoad increases flexibility. Ensure that the implications of this increased mutability are well understood and managed.
  • 19-19: Instantiating dalTableEggPrototypeHook in configWillLoad allows for dynamic configuration before the application fully loads. This is a good practice for initializing components based on configuration that may not be available at construction time.
core/dal-decorator/src/model/ColumnModel.ts (1)
  • 55-55: The adjustment of the canNull default value to false aligns with the PR's objective to enhance data integrity by enforcing non-nullability by default. This is a significant change that should be well-documented for future maintainers.
core/dal-runtime/test/fixtures/modules/generate_codes/dal/structure/Foo.sql (1)
  • 3-41: The comprehensive changes to make all columns NOT NULL in the egg_foo table align with the PR's objective to enforce non-nullability by default, enhancing data integrity. This is a significant improvement in ensuring that the database schema is robust and consistent.
core/dal-runtime/test/SqlGenerator.test.ts (1)
  • 13-51: The updates to the test case to include NOT NULL constraints in column definitions align with the changes made to the schema and ensure that the tests accurately reflect the new behavior. This is a good practice to maintain consistency between the schema and its corresponding tests.
core/dal-runtime/test/DataSource.test.ts (1)
  • 32-32: Adding a console.log statement to output the SQL query before execution can be helpful for debugging purposes. However, consider using more sophisticated logging mechanisms or conditional logging based on the environment to manage verbosity in test outputs.
core/dal-runtime/test/fixtures/modules/dal/Foo.ts (1)
  • 166-167: Adding canNull: true to the timestampColumn is an explicit exception to the PR's general objective of enforcing non-nullability by default. It's important to document the rationale behind allowing null values for this specific column to ensure clarity for future maintainers.

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 00ec4e3 and 138eba7.
Files selected for processing (1)
  • core/dal-runtime/test/SqlGenerator.test.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • core/dal-runtime/test/SqlGenerator.test.ts

Copy link

codecov bot commented Mar 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.60%. Comparing base (1c7d145) to head (138eba7).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #195      +/-   ##
==========================================
- Coverage   91.64%   91.60%   -0.05%     
==========================================
  Files         276      276              
  Lines        6442     6431      -11     
  Branches      945      932      -13     
==========================================
- Hits         5904     5891      -13     
- Misses        538      540       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@fengmk2 fengmk2 left a comment

Choose a reason for hiding this comment

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

+1

@fengmk2 fengmk2 merged commit 24628ec into master Mar 22, 2024
12 of 13 checks passed
@fengmk2 fengmk2 deleted the feat/dal branch March 22, 2024 02:10
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