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

sql/*: fix show tables to match MySQL spec #588

Merged
merged 1 commit into from
Jan 17, 2019

Conversation

erizocosmico
Copy link
Contributor

Fixes #562

  • Implements all what's in the spec for SHOW TABLES, which caused an error before even if we had show tables implemented.
  • Fixes a bug on the resolve_database analyzer rule.

Signed-off-by: Miguel Molina <miguel@erizocosmi.co>
@erizocosmico erizocosmico requested a review from a team January 17, 2019 09:59
case *plan.ShowCreateDatabase:
db, err := a.Catalog.Database(v.Database.Name())
if err != nil {
return nil, err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kind of block is almost in every case. Maybe it's good time to extract it to some function.

Copy link
Contributor Author

@erizocosmico erizocosmico Jan 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the type is different, so you can't extract it. We could extract the db, err := a.Catalog.Database(v.Database.Name()), but after error handling it would be the same amount of lines, so no point in extracting that either.

The only way I can imagine that we can use to extract this is create an interface that these nodes implement.

type Databaser interface {
  Database() sql.Database
  WithDatabase(sql.Database) (sql.Node, error)
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohh, you're right - it sucks. Let's leave it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#generics 😜

@ajnavarro ajnavarro merged commit e9244aa into src-d:master Jan 17, 2019
@erizocosmico erizocosmico deleted the fix/full-tables branch January 17, 2019 11:39
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.

[SQLAlchemy] missing column in SHOW FULL TABLES
3 participants