Skip to content

fix: switch meeting schema to use text type where appropriate - #21610

Merged
antobinary merged 1 commit into
bigbluebutton:v3.0.x-releasefrom
danimo:fix/21609
Nov 4, 2024
Merged

antobinary merged 1 commit into
bigbluebutton:v3.0.x-releasefrom
danimo:fix/21609

Conversation

@danimo

@danimo danimo commented Nov 4, 2024 •

Copy link
Copy Markdown
Contributor

fixes #21609 by changing the type of some varchar fields to type text.

@coderabbitai

coderabbitai Bot commented Nov 4, 2024 •

Copy link
Copy Markdown
Contributor

Walkthrough

The pull request introduces significant modifications to the SQL schema in the bbb-graphql-server/bbb_schema.sql file, particularly affecting the meeting and user tables. Key changes include the addition of two new functions: immutable_lower_unaccent(text) for converting text to lowercase with unaccenting, and remove_emojis(text) for removing emojis using a regular expression. The meeting table is updated by changing several column data types from varchar to text, adding new columns such as createdAt and ended, and implementing triggers for automatic field updates. The user table enhancements include the addition of multiple generated columns that reflect user roles and statuses, such as nameSortable, isModerator, and others. Additionally, the schema introduces new views to align with the updated structure. Overall, these changes aim to improve the handling of user and meeting data by enhancing flexibility and dynamic calculations.

Assessment against linked issues

Objective Addressed Explanation
Change meeting.extId and other varchar columns to text type (21609) ✅
Ensure no restrictions on the length of external Meeting ID (21609) ✅

Possibly related PRs

Suggested reviewers

  • KDSBrowne
  • TiagoJacobs

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>, please review it.
    • 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 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 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 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 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
bbb-graphql-server/bbb_schema.sql (1)

Line range hint 1-1024: Consider extending the text type changes to other similar columns.

For consistency and to prevent similar issues, consider changing these columns to text type as well:

  • meeting_metadata.value: currently varchar(1000)
  • user.name: currently varchar(255)
  • user.avatar: currently varchar(500)
  • chat_message.senderName: currently varchar(255)

This would:

  • Maintain consistency across the schema
  • Prevent potential similar issues in these tables
  • Follow the same PostgreSQL best practices
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d32676b and 3d4ce45.

📒 Files selected for processing (1)
  • bbb-graphql-server/bbb_schema.sql (1 hunks)
🔇 Additional comments (1)
bbb-graphql-server/bbb_schema.sql (1)

23-24: LGTM! The column type changes appropriately address the length restriction issue.

The changes from varchar to text type are well-justified:

  • Removes arbitrary length restrictions that were causing issues with external Meeting IDs
  • Follows PostgreSQL best practices as text has no performance overhead compared to varchar
  • Consistently applied to all similar fields (URLs and text content)

Also applies to: 31-36

@danimo danimo changed the title fix: switch meeting schema to use text type where approriate fix: switch meeting schema to use text type where appropriate Nov 4, 2024
@sonarqubecloud

sonarqubecloud Bot commented Nov 4, 2024

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
bbb-graphql-server/bbb_schema.sql (2)

Line range hint 1-1000: Consider updating related table column types for consistency.

While the main meeting table columns have been updated to use text, several related tables still use varchar for similar data types. Consider updating these for consistency:

  1. Foreign key columns referencing meeting.meetingId
  2. Similar text fields in related tables that might benefit from the same treatment

Example tables to review:

  • meeting_breakout
  • meeting_metadata
  • meeting_welcome

Line range hint 1-1000: Consider implementing additional schema best practices.

While addressing the immediate issue, consider these improvements for maintainability:

  1. Standardize identifier quoting:

    • Currently mixing quoted ("meetingId") and unquoted (meetingId) identifiers
    • Choose one style and apply consistently
  2. Add explicit names for constraints and indexes:

    • Some constraints use default names
    • Explicit names improve maintainability and error messages
  3. Document column type decisions:

    • Add comments explaining the rationale for text vs. varchar choices
    • Help prevent future regressions
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 3d4ce45 and 8eb8e34.

📒 Files selected for processing (1)
  • bbb-graphql-server/bbb_schema.sql (1 hunks)
🔇 Additional comments (2)
bbb-graphql-server/bbb_schema.sql (2)

23-24: LGTM: Column type changes align with requirements and best practices.

The changes from varchar to text type for the following columns are appropriate:

  • extId and name: Removes the 100-character limitation that was causing issues
  • URL fields: Removes the 500-character limitation for consistency

This change follows PostgreSQL best practices as there's no performance benefit to using varchar over text.

Also applies to: 31-36


23-24: Verify application code for varchar length assumptions.

Let's verify there are no hardcoded assumptions about field lengths in the application code that might need updating.

✅ Verification successful

Let me analyze the findings from the executed scripts:

  1. No hardcoded length checks or validations specifically for extId were found in the application code.
  2. The field is used primarily for identification and reference purposes in various parts of the application.
  3. The only length-related constraints found in the codebase are for other fields (e.g., maxLength=128 for waiting users, maxLength=255 for breakout rooms).
  4. No string truncation operations were found on the extId field.

No impact on application code from varchar length change.

The change from varchar(100) to text for the extId field appears safe as there are no hardcoded length validations or truncations in the application code that would be affected by this change.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for potential hardcoded length checks or assumptions

# Check for length checks on extId
rg -g '!*.sql' -i 'length.*extId|extId.*length|varchar.*100|maxLength'

# Check for string truncation
rg -g '!*.sql' -i 'substring.*extId|substr.*extId|left.*extId'

Length of output: 190579

@antobinary antobinary added this to the Release 3.0 milestone Nov 4, 2024
@antobinary
antobinary merged commit 234235d into bigbluebutton:v3.0.x-release Nov 4, 2024
@github-actions

github-actions Bot commented Nov 4, 2024

Copy link
Copy Markdown

Automated tests Summary

🚨 Test workflow has failed


Click here to check the action test reports

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.

bbb-graphql-server: Undue restrictions in SQL schema

2 participants