Skip to content

SetOptionSync and different Connect methods #156

Open
@anton-kotenko

Description

@anton-kotenko

I'm working on "Load data infile" feature. It's work requires to set MYSQL_OPT_LOCAL_INFILE option. But i've found
that it's impossible to set options if using ConnectSync or Connect methods
and that the only way to set options is like this:

var mysql = require('mysql-libmysqlclient'),
conn = new mysql.bindings.MysqlConnection();
conn.initSync();
conn.setOptionSync(mysq.MYSQL_OPT_LOCAL_INFILE);
conn.realConnectSync(host, user, password, dbname);

As for me, it make's api inconsistent (i can not set options, if i want to connect in asyncronous mode), and introduces additional difficulties (at least 2 methods initSync, and realConnectSync).
So my proposal is to have _conn structrure initialized in constructor, (and every time when it closed, like when mysql_real_connect fails).
This makes possible to use setOptionSync between new MysqlConnection and any form of Connect method.
and makes possible to remove initSync and realConnectSync (and also remove RealConnect method from mysql_bindings_connection.cc, as it's almost copy&paste of Connect method)

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions