Skip to content

Implement ColumnType interface #495

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

Closed
julienschmidt opened this issue Oct 24, 2016 · 3 comments
Closed

Implement ColumnType interface #495

julienschmidt opened this issue Oct 24, 2016 · 3 comments
Milestone

Comments

@julienschmidt
Copy link
Member

See golang/go@2a85578 and golang/go#16652

@hasryan
Copy link

hasryan commented Jan 29, 2017

I have an immediate need for this functionality in a small project I am working on, so I hacked together a partial, very rough implementation for the single interface I need: hasryan@f2e81dd

When I was working on that I noticed that empty results are represented by the emptyRows{} struct which simply returns nil from its Columns() method. I think column details are still available from MySQL even if the result set is empty, so it would be nice if when these new interfaces are implemented it includes the ability to get column details for empty results as well.

My use case is one where I am executing ad-hoc queries against MySQL and replicating the results into another database (SQLite in my case). I need the type information from MySQL so that I can create appropriately-typed columns in the SQLite table I generate. An empty resultset is valid, and I would like to be able to create an empty table with correctly-typed columns.

@torkelo
Copy link

torkelo commented Apr 21, 2017

This i also something I would find very useful (working on MySQL data source support in Grafana where I need to visualize ad-hoc SQL queries in different forms) and knowing column types is going to be very important.

@hasryan any plans to open a PR for your implementation?

@hasryan
Copy link

hasryan commented May 10, 2017

@torkelo sorry for not responding sooner. I do not have any immediate plans to open a PR because I suspect my referenced implementation is not up to to the quality standards of this project. It's something I put together that worked for me in my specific use case, but I have not had enough time to review the codebase to know if it is consistent with existing patterns. Also, I only implemented one of the five new interfaces.

pteichman pushed a commit to pteichman/mysql that referenced this issue Jul 21, 2017
This is a temporary move until the columntype branch lands
upstream.

Implementation here:
go-sql-driver#495
@julienschmidt julienschmidt mentioned this issue Oct 6, 2017
5 tasks
daniellee added a commit to grafana/grafana that referenced this issue Jan 18, 2018
The latest master implements the ColumnType interface.

See go-sql-driver/mysql#495

This removes the custom code in the vendor folder that
did a ColumnType mapping.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants