Skip to content

mysql - feat: moving to native namespacing#1864

Merged
jaredwray merged 6 commits intomainfrom
mysql---feat-moving-to-native-namespacing
Feb 25, 2026
Merged

mysql - feat: moving to native namespacing#1864
jaredwray merged 6 commits intomainfrom
mysql---feat-moving-to-native-namespacing

Conversation

@jaredwray
Copy link
Owner

@jaredwray jaredwray commented Feb 24, 2026

Please check if the PR fulfills these requirements

  • Followed the Contributing and Code of Conduct guidelines.
  • Tests for the changes have been added (for bug fixes/features) with 100% code coverage.

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
mysql - feat: moving to native namespacing

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jaredwray, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the Keyv MySQL adapter by implementing native namespacing. Instead of relying on key prefixes, a dedicated namespace column is now used, improving data isolation, query efficiency, and overall robustness for multi-tenant or multi-application caching scenarios. This change includes automatic schema migration for existing installations and comprehensive updates to all data access methods to leverage the new structure.

Highlights

  • Native Namespacing Implementation: The MySQL adapter now supports native namespace scoping by introducing a dedicated namespace column in the database table. This provides efficient filtering and proper isolation between different namespaces.
  • Database Schema Migration: Automatic migration logic has been added to handle existing tables, including adding the new namespace column, dropping the old single-column primary key, and creating a new composite unique index on id and namespace.
  • Updated CRUD Operations: All core Keyv operations (get, set, delete, clear, iterator, has, getMany, setMany, deleteMany, hasMany) have been updated to correctly utilize the new namespace column for data isolation and retrieval.
  • Enhanced Test Coverage: New tests have been added to thoroughly validate the native namespacing functionality, ensuring proper behavior for independent storage, clearing, deletion, and iteration across different namespaces.
  • Documentation Update: The README.md has been updated to include a new section detailing the namespace support, its benefits, and usage examples.
Changelog
  • storage/mysql/README.md
    • Added 'Namespace Support' section to the table of contents.
    • Included detailed documentation for the new native namespace feature, explaining its benefits and providing usage examples.
  • storage/mysql/src/index.ts
    • Added namespaceLength option to the adapter configuration.
    • Modified the CREATE TABLE statement to include a namespace column and a composite unique index on id and namespace.
    • Implemented migration logic to add the namespace column, drop the old primary key, and create the new composite unique index for existing tables.
    • Introduced removeKeyPrefix and getNamespaceValue helper methods for consistent namespace handling.
    • Updated get, getMany, set, setMany, delete, deleteMany, clear, iterator, has, and hasMany methods to incorporate the namespace column in SQL queries for proper data isolation.
  • storage/mysql/src/types.ts
    • Added namespaceLength property to the KeyvMysqlOptions type definition.
  • storage/mysql/test/test.ts
    • Added beforeEach hooks to clear namespaced entries for test isolation.
    • Introduced a comprehensive suite of new tests to verify native namespacing functionality across various operations like set, get, clear, delete, deleteMany, has, hasMany, iterator, and inter-namespace conflict prevention.
Activity
  • The author, jaredwray, initiated this pull request to introduce native namespacing for the MySQL adapter.
  • The pull request description indicates that the changes are a feature (feat) related to MySQL.
  • The author has marked the 'Followed the Contributing and Code of Conduct guidelines' checkbox as complete.
  • The author has indicated that tests for the changes have been added, aiming for 100% code coverage, which is reflected in the added test file.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 134079e66e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces native namespacing for the MySQL adapter, a significant improvement over key-prefixing. However, a high-severity SQL injection vulnerability exists in the database initialization and migration logic. The unique index name is constructed using the table option without proper escaping, which could allow an attacker to execute arbitrary SQL commands. This also poses a risk of SQL errors if table names contain special characters. Addressing the index name construction is critical for both security and robustness.

@codecov
Copy link

codecov bot commented Feb 24, 2026

Codecov Report

❌ Patch coverage is 99.28571% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 99.92%. Comparing base (df818b9) to head (91b50ba).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
storage/mysql/src/index.ts 99.28% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1864      +/-   ##
==========================================
- Coverage   99.96%   99.92%   -0.04%     
==========================================
  Files          32       32              
  Lines        2606     2701      +95     
  Branches      460      472      +12     
==========================================
+ Hits         2605     2699      +94     
- Misses          1        2       +1     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jaredwray jaredwray merged commit 1eb2029 into main Feb 25, 2026
8 checks passed
@jaredwray jaredwray deleted the mysql---feat-moving-to-native-namespacing branch February 25, 2026 01:15
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.

1 participant