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

db.schema.hasTable('') returns true #2065

Closed
capaj opened this issue May 15, 2017 · 2 comments
Closed

db.schema.hasTable('') returns true #2065

capaj opened this issue May 15, 2017 · 2 comments
Labels

Comments

@capaj
Copy link
Contributor

capaj commented May 15, 2017

This may be some weird behaviour of mysql I don't know about, but shouldn't this method return false?

const hasTable = await db.schema.hasTable('')
  if (hasTable) {
    console.log('hasTable: ', hasTable)

debug output:

  knex:query show tables like ? +2ms
  knex:bindings [ '' ] +0ms
  knex:client releasing connection to pool: __knexUid1 +10ms
  knex:pool INFO pool mysql:mysql:client0 - dispense() clients=0 available=3 +1ms
hasTable:  true

On Knex 0.13.0

@elhigu
Copy link
Member

elhigu commented May 16, 2017

looks like it is not exact match, that hasTable does on mysql:

MariaDB [knex_test]> show tables like '';
+----------------------------+
| Tables_in_knex_test ()     |
+----------------------------+
| 10_test_table              |
| BatchInsert                |
| accounts                   |
| batchInsertDuplicateKey    |
| bool_test                  |
| catch_test                 |
| charset_collate_test       |
| composite_key_test         |
| datatype_test              |
| invalid_inTable_param_test |
| knex_migrations            |
| knex_migrations_lock       |
| person                     |
| primarytest                |
| renameColTest              |
| taabl                      |
| test_default_table         |
| test_default_table2        |
| test_table                 |
| test_table_two             |
+----------------------------+
20 rows in set (0.00 sec)

MariaDB [knex_test]> 

I would consider this as a knex bug. Knex should check that exact match was found in the returned table list or change query to be something that throws an error if table doesn't exist like shown here http://stackoverflow.com/a/8829109/360060

@elhigu
Copy link
Member

elhigu commented Jun 9, 2017

Fixed via #2097

@elhigu elhigu closed this as completed Jun 9, 2017
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