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

TypeError: Cannot read property 'addItem' of undefined #242

Closed
saulfautley opened this issue May 22, 2019 · 4 comments

Comments

2 participants
@saulfautley
Copy link

commented May 22, 2019

Describe the bug
Just installed SQLTools for the first time and can't seem to get past this error after adding a new connection:
Error while trying to create columns tree for MySQL Cannot read property 'addItem' of undefined

Screenshots
image
image
image

Desktop (please complete the following information):

  • SQLTools Version: 0.19.1
  • VSCode Version: 1.34.0
  • Dialect Used: MySQL
  • OS: Windows

Additional context
Using MySQL docker container as server. Databases show in the Connections pane, but they are a bit messed up and don't show all tables, etc.

@saulfautley saulfautley added the bug label May 22, 2019

@project-bot project-bot bot added this to To do in Kanban May 22, 2019

@mtxr

This comment has been minimized.

Copy link
Owner

commented May 23, 2019

@saulfautley would you mind sharing the result of this query? Even with the explorer tree not working you should be able to run queries.

SELECT
  C.TABLE_NAME AS tableName,
  C.COLUMN_NAME AS columnName,
  C.DATA_TYPE AS type,
  C.CHARACTER_MAXIMUM_LENGTH AS size,
  C.TABLE_SCHEMA as tableSchema,
  C.TABLE_CATALOG AS tableCatalog,
  C.TABLE_SCHEMA as tableDatabase,
  C.COLUMN_DEFAULT as defaultValue,
  C.IS_NULLABLE as isNullable,
  C.ORDINAL_POSITION,
  (
    CASE
      WHEN C.COLUMN_KEY = 'PRI' THEN TRUE
      ELSE FALSE
    END
  ) as isPk,
  (
    CASE
      WHEN KCU.REFERENCED_COLUMN_NAME IS NULL THEN FALSE
      ELSE TRUE
    END
  ) as isFk,
  CONCAT(
    C.TABLE_SCHEMA,
    '//SEP//',
    (
      CASE
        WHEN T.TABLE_TYPE = 'VIEW' THEN 'views'
        ELSE 'tables'
      END
    ),
    '//SEP//',
    C.TABLE_name,
    '//SEP//',
    C.COLUMN_NAME
  ) AS tree
FROM
  INFORMATION_SCHEMA.COLUMNS AS C
  LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU ON (
    C.TABLE_CATALOG = KCU.TABLE_CATALOG
    AND C.TABLE_NAME = KCU.TABLE_NAME
    AND C.TABLE_SCHEMA = KCU.TABLE_SCHEMA
    AND C.TABLE_CATALOG = KCU.TABLE_CATALOG
    AND C.COLUMN_NAME = KCU.COLUMN_NAME
  )
  JOIN INFORMATION_SCHEMA.TABLES AS T ON C.TABLE_NAME = T.TABLE_NAME
  AND C.TABLE_SCHEMA = T.TABLE_SCHEMA
  AND C.TABLE_CATALOG = T.TABLE_CATALOG
WHERE
  C.TABLE_SCHEMA NOT IN ('information_schema', 'performance_schema', 'mysql', 'sys')
ORDER BY
  C.TABLE_NAME,
  C.ORDINAL_POSITION

If you prefer, you can send it to me via email: matheus@mteixeira.dev

What is happening is that somewhere in the tree we might have found a char that is breaking the tree creator, so I will need to now if we have an invalid char in the tree prop this query returns.

If you want to try to debug it and submit a PR, here is where it's breaking:

tree.addItem(new SidebarResourceGroup(g, hierachyNames[i]));

@saulfautley

This comment has been minimized.

Copy link
Author

commented May 23, 2019

Looks like the issue is due to one of my databases having a . in its name. Tested with a fresh container, created a new database test_1, worked fine in SQLTools. Copied the database to test_2.0, refreshed SQLTools and immediately got the same error.

@mtxr

This comment has been minimized.

Copy link
Owner

commented May 23, 2019

Got it! Thanks! I'll fix that tonight

@mtxr mtxr added enhancement and removed needs more info labels May 24, 2019

@mtxr mtxr closed this in b2ee063 May 24, 2019

Kanban automation moved this from To do to To be released May 24, 2019

@mtxr

This comment has been minimized.

Copy link
Owner

commented Jun 2, 2019

Hi @saulfautley!

How is it going with the extension? Is it working as expected now? Hope so!

Just came to remember, if you like the project, please consider a donation or reviewing it on VSCode marketplace. That you help it to keep evolving.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.