shiba icon indicating copy to clipboard operation
shiba copied to clipboard

Handle table aliases for MySQL queries

Open kianris opened this issue 5 years ago • 4 comments

I've been testing out Shiba with queries in a log file for a non-Ruby project. It seems like some queries are working with aliases but not others. Is this because there is no SQL parsing performed within Shiba yet?

Alternatively I could list the aliases as part of the /*shiba*/ metadata with each query.

kianris avatar Jun 25 '19 02:06 kianris

I'll take a look at this. Can you include a sample from your log file of a query or two that aren't working?

eac avatar Jun 26 '19 07:06 eac

In MySQL:

create table Shiba(id bigint not null auto_increment, primary key(id), value varchar(255));

Explain and review without alias select * from Shiba

select * from Shiba:-2 ()
 * Table Scan: mysql reads 100% (1000) of the of the rows in **Shiba**, skipping any indexes.
 * Estimated query time: 0.01s

Explain and review with alias select * from Shiba s

<No output>

kianris avatar Jun 27 '19 01:06 kianris

Fix is almost ready, I'll try to get a release out in the next few days.

eac avatar Jul 02 '19 02:07 eac

I've released support for capitalized table names and aliases for simple queries on mysql. More complex queries featuring joins aren't supported.

eac avatar Jul 02 '19 19:07 eac