Problem description:
Using the current version of the replit’s database package you can create undeletable keys.
Expected behavior:
client.empty();
Deletes all keys from the database.
Actual behavior:
It doesn’t delete keys with a newline in them.
Steps to reproduce:
- Create a new repl
- Import the replit database package:
const Client = require("@replit/database");
const client = new Client();
- Create a an iife function so we can use
async/await
:
(async () => {
// Code goes here
})();
- Fill the function:
(async () => {
// create a new key
await client.set("another\nnew\nline\n", "key");
// empty db
await client.empty();
// get all keys
const db = await client.getAll();
// So now the db must be empty, right... Right?
console.log(db);
})();
And tada:
You can run the code here.
Solution:
I created a pull request which fixes the issue and also drastically improves code performance as seen here:
You can run the comparison here.