Skip to content
This repository has been archived by the owner on Jan 28, 2021. It is now read-only.

plan: types in lowecase on SHOW CREATE TABLE #656

Merged
merged 1 commit into from
Apr 9, 2019
Merged

plan: types in lowecase on SHOW CREATE TABLE #656

merged 1 commit into from
Apr 9, 2019

Conversation

mcuadros
Copy link
Contributor

@mcuadros mcuadros commented Apr 4, 2019

Signed-off-by: Máximo Cuadros mcuadros@gmail.com

As seen in MySQL the types in a SHOW CREATE TABLE result should be written lowercase.
This is a requirement to make work properly SQLAlchemey, you can test the current issues with this small script:

import sqlalchemy
from sqlalchemy import inspect

engine = sqlalchemy.create_engine('mysql+pymysql://root:@127.0.0.1:3306/mydb')
with engine.connect() as conn:
    inspector = inspect(engine)

    cols = inspector.get_columns("commits", "gitbase")

Result:

✗ gitbase (master) ✗ python foo.py
/usr/lib/python3.7/site-packages/sqlalchemy/dialects/mysql/reflection.py:193: SAWarning: Did not recognize type 'TEXT' of column 'repository_id'
  "Did not recognize type '%s' of column '%s'" % (type_, name)
/usr/lib/python3.7/site-packages/sqlalchemy/dialects/mysql/reflection.py:193: SAWarning: Did not recognize type 'TEXT' of column 'commit_hash'
  "Did not recognize type '%s' of column '%s'" % (type_, name)
/usr/lib/python3.7/site-packages/sqlalchemy/dialects/mysql/reflection.py:193: SAWarning: Did not recognize type 'TEXT' of column 'commit_author_name'
  "Did not recognize type '%s' of column '%s'" % (type_, name)
/usr/lib/python3.7/site-packages/sqlalchemy/dialects/mysql/reflection.py:193: SAWarning: Did not recognize type 'TEXT' of column 'commit_author_email'
  "Did not recognize type '%s' of column '%s'" % (type_, name)
/usr/lib/python3.7/site-packages/sqlalchemy/dialects/mysql/reflection.py:193: SAWarning: Did not recognize type 'TIMESTAMP' of column 'commit_author_when'
  "Did not recognize type '%s' of column '%s'" % (type_, name)
/usr/lib/python3.7/site-packages/sqlalchemy/dialects/mysql/reflection.py:193: SAWarning: Did not recognize type 'TEXT' of column 'committer_name'
  "Did not recognize type '%s' of column '%s'" % (type_, name)
/usr/lib/python3.7/site-packages/sqlalchemy/dialects/mysql/reflection.py:193: SAWarning: Did not recognize type 'TEXT' of column 'committer_email'
  "Did not recognize type '%s' of column '%s'" % (type_, name)

How looks like a SHOW CREATE TABLE in MySQL

| wp_links | CREATE TABLE `wp_links` (
  `link_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `link_url` varchar(255) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '',
  `link_name` varchar(255) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '',
  `link_image` varchar(255) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '',
  `link_target` varchar(25) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '',
  `link_description` varchar(255) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '',
  `link_visible` varchar(20) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT 'Y',
  `link_owner` bigint(20) unsigned NOT NULL DEFAULT '1',
  `link_rating` int(11) NOT NULL DEFAULT '0',
  `link_updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `link_rel` varchar(255) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '',
  `link_notes` mediumtext COLLATE utf8mb4_unicode_520_ci NOT NULL,
  `link_rss` varchar(255) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '',
  PRIMARY KEY (`link_id`),
  KEY `link_visible` (`link_visible`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci |````

Signed-off-by: Máximo Cuadros <mcuadros@gmail.com>
@erizocosmico
Copy link
Contributor

@ajnavarro shall we merge this?

@ajnavarro ajnavarro merged commit 53adb3b into src-d:master Apr 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants