sidorares / sidorares/node-mysql2
Error 'No database selected' on simple SQL-Command ('DELETE')
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 4.4k
- Forks
- 680
- Avg merge
- 9h 7m
- Merged PRs (30d)
- 59
Description
Using the SQL-Command 'DELETE' raises the Error 'No database selected'. Other SQL-Commands work without any error.
The error is reproducible with the following Test:
1) Create Schema, Table and Testdata
CREATE SCHEMA `testSchema` ;
CREATE TABLE `testSchema`.`testTable` (
`idtestTable` INT NOT NULL,
`text` VARCHAR(45) NULL,
PRIMARY KEY (`idtestTable`));
INSERT INTO `testSchema`.`testTable` (`idtestTable`, `text`) VALUES ('1', 'text1');
INSERT INTO `testSchema`.`testTable` (`idtestTable`, `text`) VALUES ('2', 'text2');
INSERT INTO `testSchema`.`testTable` (`idtestTable`, `text`) VALUES ('3', 'text2');
2) Create pool within node and execute simple DELETE command
Create a pool within node by the command mysql2.createPool({ ... }), using the parameters: host, port, user, password, waitForConnections, connectionLimit, queueLimit (without default database)
Execute the following DELETE-Command:
pool.query('DELETE `X` FROM `testSchema`.`testTable` AS `X` WHERE `X`.`idtestTable` = 2;');
3) Error result
message: 'No database selected',
code: 'ER_NO_DB_ERROR',
errno: 1046,
sqlState: '3D000',
sqlMessage: 'No database selected'
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied schema, table, and data setup, then reproduce the pool.query DELETE call with no default database. Compare its handling with the other SQL commands that succeed; done means the qualified DELETE completes without ER_NO_DB_ERROR under the same pool configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, nodejs, typescript
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100