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

key and blob are reserved words in MySQL, so everything fails: table creation, retrieval, etc. #537

Closed
ernestoalejo opened this issue Dec 25, 2024 · 1 comment · Fixed by #542
Labels
bug Something isn't working

Comments

@ernestoalejo
Copy link

Environment

unstorage 1.14.1
node v20.18.0
mysql 8.0.33

Reproduction

import { createDatabase } from 'db0'
import mysql from 'db0/connectors/mysql2'

const db = createDatabase(
  mysql({
    database: createDatabase(mysql({ uri: process.env.DATABASE_URL })),
  }),
)

Describe the bug

key and blob are reserved words and cannot be used in mysql without escaping them first.

It throws errors for example in this line of code:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VARCHAR(255) NOT NULL PRIMARY KEY,
        value LONGTEXT,
        blob BLOB,

And errors in other places like this:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key = 'foo'' at line 1

Additional context

Column names can be escaped with the "`" character though it might be inconvenient in Javascript because it breaks template strings. Alternatively the columns can use other non-reserved words.

Logs

No response

@ernestoalejo ernestoalejo added the bug Something isn't working label Dec 25, 2024
@pi0 pi0 closed this as completed in #542 Dec 26, 2024
@pi0
Copy link
Member

pi0 commented Dec 26, 2024

Thanks for report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants