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

Prefix is doubled in table create method #963

Closed
rvalitov opened this issue May 12, 2021 · 1 comment
Closed

Prefix is doubled in table create method #963

rvalitov opened this issue May 12, 2021 · 1 comment
Labels

Comments

@rvalitov
Copy link

Describe the bug
When I create a database with prefix option in config, the resulting table has a doubled prefix. This happens only at create method. Other methods insert and update work correctly and format a table name with a single prefix.

Information

  • Version of Medoo: v2.0.0
  • Type of Database (MySQL, MSSQL, SQLite...): MariaDB 10.5.9
  • System (Liunx\Windows\Mac): Debian 10

Detail Code
Config example:

new Medoo([
            // [required]
            'type' => 'mysql',
            'socket' => '/var/run/mysqld/mysqld.sock',
            'database' => 'c1hbm',
            'username' => 'c1hbm',
            'password' => 'xxxx',

            // [optional]
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_general_ci',

            // [optional] Table prefix, all table names will be prefixed as PREFIX_table.
            'prefix' => 'HBM_',

            // [optional] Enable logging, it is disabled by default for better performance.
            'logging' => true,

            // [optional]
            // Error mode
            // Error handling strategies when error is occurred.
            // PDO::ERRMODE_SILENT (default) | PDO::ERRMODE_WARNING | PDO::ERRMODE_EXCEPTION
            // Read more from https://www.php.net/manual/en/pdo.error-handling.php.
            'error' => PDO::ERRMODE_SILENT,
        ]);

After I call

$db->create('products',[
            "id" => [
                "INT",
                "DEFAULT NULL",
                "AUTO_INCREMENT",
                "PRIMARY KEY",
            ],
            "product_id" => [
                "VARCHAR(30)",
                "NOT NULL",
                "COMMENT 'Original product ID'",
            ],
            "name" => [
                "VARCHAR(255)",
                "NOT NULL",
                "COMMENT 'Product name'",
            ],
        ]);

In phpmyadmin I see a table named HBM_HBM_products.

Expected output
I expect to see a table named HBM_products. When I call commands like insert or update - they correctly refer to HBM_products table and as a result lead to error:

42S02
Table 'c1hbm.HBM_products' doesn't exist 
@catfan
Copy link
Owner

catfan commented May 12, 2021

Thanks for the feedback. It's fixed on 7d9ac11.

@catfan catfan added the bug label May 13, 2021
@catfan catfan closed this as completed May 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants