Return full command object
kwent opened this issue · comments
Return full command object
My app was relying on executionType
attribute from the command
object returned by https://github.com/maxcnunes/sql-query-identifier but starting 7.4.0
, sqlectron-core
is just returning type
attribute for all clients. Cause this modification: 770b06c#diff-2f30d89cc6b8682e2400496f14c263e2R265. Why this breaking behavior ?
I try to hack around and reverse the .map((item) => item.type);
. Everything works as i expect again except for sqlite
client who works a bit differently and return just the type
. I would love to have the full object with executionType
as well to be consistent with all other clients.
Regards
You could make sqlite to return the full command information by changing this
command: statement.type || (isSelect && 'SELECT'),
to this
command: statement || (isSelect && 'SELECT'),
I don't remember well but I guess the idea never was to provide the whole command. Because we just use sql-query-identifier
if the db client does not provide the query type or can't handle multiple queries statements. Is not always we have the full command information. So I don't suggest making that change.
Although you can still resolve the executionType through EXECUTION_TYPES. That is not exported but you should be able to access that by
const { EXECUTION_TYPES } from 'sql-query-identifier/lib/parser';
const executionType = EXECUTION_TYPES[query.command];
Thank you for your answer. I ended up using EXECUTION_TYPES
as your suggested. Thanks