Skip to content
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

fix: made to work with node 14+ #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
node_modules
42 changes: 42 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
"author": "SQL ANYWHERE",
"name": "sqlanywhere",
"description": "SQL Anywhere JavaScript Driver.",
"version": "1.0.25",
"version": "2.0.3",
"repository": {
"url": "https://github.com/sqlanywhere/node-sqlanywhere"
},
"main": "./lib/index",
"engines": {
"node": ">=0.10"
"node": ">=14.0.0"
},
"scripts": {
"install": "node build.js"
},
"dependencies": {
"help": "^3.0.2",
"nan": "2.14.2"
"nan": "^2.15.0"
}
}
84 changes: 38 additions & 46 deletions src/h/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,38 +136,30 @@ using namespace node;
*/
class Connection : public ObjectWrap
{
public:
public:
/// @internal
#if v010
static void Init();
#else
static void Init( Isolate * );
#endif
static void Init(Isolate *);

/// @internal
static NODE_API_FUNC( NewInstance );
private:
static NODE_API_FUNC(NewInstance);

private:
/// @internal
#if v010
Connection( const Arguments &args );
#else
Connection( const FunctionCallbackInfo<Value> &args );
#endif
Connection(const FunctionCallbackInfo<Value> &args);
/// @internal
~Connection();

/// @internal
static Persistent<Function> constructor;

/// @internal
static void noParamAfter( uv_work_t *req );
static void noParamAfter(uv_work_t *req);
/// @internal
static void connectAfter( uv_work_t *req );
static void connectAfter(uv_work_t *req);
/// @internal
static void connectWork( uv_work_t *req );
static void connectWork(uv_work_t *req);
/// @internal
static NODE_API_FUNC( New );
static NODE_API_FUNC(New);

/// Connect using an existing connection.
//
Expand Down Expand Up @@ -202,7 +194,7 @@ class Connection : public ObjectWrap
//
// @internal
///

/** Creates a new connection.
*
* This method creates a new connection using either a connection string
Expand Down Expand Up @@ -242,7 +234,7 @@ class Connection : public ObjectWrap
*
* @see Connection::disconnect
*/
static NODE_API_FUNC( connect );
static NODE_API_FUNC(connect);

/** Closes the current connection.
*
Expand Down Expand Up @@ -275,11 +267,11 @@ class Connection : public ObjectWrap
*
* @see Connection::connect
*/
static NODE_API_FUNC( disconnect );
static NODE_API_FUNC(disconnect);

/// @internal
static void disconnectWork( uv_work_t *req );
static void disconnectWork(uv_work_t *req);

/** Executes the specified SQL statement.
*
* This method takes in a SQL statement and an optional array of bind
Expand Down Expand Up @@ -335,8 +327,8 @@ class Connection : public ObjectWrap
* @return If no callback is specified, the result is returned.
*
*/
static NODE_API_FUNC( exec );
static NODE_API_FUNC(exec);

/** Prepares the specified SQL statement.
*
* This method prepares a SQL statement and returns a Statement object
Expand Down Expand Up @@ -373,13 +365,13 @@ class Connection : public ObjectWrap
* @return If no callback is specified, a Statement object is returned.
*
*/
static NODE_API_FUNC( prepare );
static NODE_API_FUNC(prepare);

/// @internal
static void prepareAfter( uv_work_t *req );
static void prepareAfter(uv_work_t *req);
/// @internal
static void prepareWork( uv_work_t *req );
static void prepareWork(uv_work_t *req);

/** Performs a commit on the connection.
*
* This method performs a commit on the connection.
Expand Down Expand Up @@ -421,11 +413,11 @@ class Connection : public ObjectWrap
* @param callback The optional callback function. ( type: Function )
*
*/
static NODE_API_FUNC( commit );
static NODE_API_FUNC(commit);

/// @internal
static void commitWork( uv_work_t *req );
static void commitWork(uv_work_t *req);

/** Performs a rollback on the connection.
*
* This method performs a rollback on the connection.
Expand Down Expand Up @@ -465,10 +457,10 @@ class Connection : public ObjectWrap
* @param callback The optional callback function. ( type: Function )
*
*/
static NODE_API_FUNC( rollback );
static NODE_API_FUNC(rollback);

/// @internal
static void rollbackWork( uv_work_t *req );
static void rollbackWork(uv_work_t *req);

/** Indicates whether the connection is connected.
*
Expand All @@ -492,24 +484,24 @@ class Connection : public ObjectWrap
* @return true if the connection is connected, false if not.
*
*/
static NODE_API_FUNC( connected );
static NODE_API_FUNC(connected);

public:
public:
/// @internal
a_sqlany_connection *conn;
a_sqlany_connection *conn;
/// @internal
unsigned int max_api_ver;
unsigned int max_api_ver;
/// @internal
bool sqlca_connection;
bool sqlca_connection;
/// @internal
uv_mutex_t conn_mutex;
uv_mutex_t conn_mutex;
/// @internal
Persistent<String> _arg;
Persistent<String> _arg;
/// @internal
std::vector<void*> statements;
std::vector<void *> statements;

/// @internal
void removeStmt( class StmtObject *stmt );
void removeStmt(class StmtObject *stmt);
/// @internal
void cleanupStmts( void );
void cleanupStmts(void);
};
18 changes: 9 additions & 9 deletions src/h/errors.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// ***************************************************************************
// Copyright (c) 2021 SAP SE or an SAP affiliate company. All rights reserved.
// ***************************************************************************
#define JS_ERR_INVALID_OBJECT -2001
#define JS_ERR_INVALID_ARGUMENTS -2002
#define JS_ERR_CONNECTION_ALREADY_EXISTS -2003
#define JS_ERR_INITIALIZING_DBCAPI -2004
#define JS_ERR_NOT_CONNECTED -2005
#define JS_ERR_BINDING_PARAMETERS -2006
#define JS_ERR_GENERAL_ERROR -2007
#define JS_ERR_RESULTSET -2008
#define JS_ERR_NO_WIDE_STATEMENTS -2009
#define JS_ERR_INVALID_OBJECT -2001
#define JS_ERR_INVALID_ARGUMENTS -2002
#define JS_ERR_CONNECTION_ALREADY_EXISTS -2003
#define JS_ERR_INITIALIZING_DBCAPI -2004
#define JS_ERR_NOT_CONNECTED -2005
#define JS_ERR_BINDING_PARAMETERS -2006
#define JS_ERR_GENERAL_ERROR -2007
#define JS_ERR_RESULTSET -2008
#define JS_ERR_NO_WIDE_STATEMENTS -2009
17 changes: 1 addition & 16 deletions src/h/nodever_cover.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,4 @@
// ***************************************************************************
#include <node_version.h>

#if NODE_MAJOR_VERSION == 0 && NODE_MINOR_VERSION == 10
#define v010 1
#define v012 0
#elif NODE_MAJOR_VERSION == 0 && NODE_MINOR_VERSION == 12
#define v010 0
#define v012 1
#else
#define v010 0
#define v012 0
#endif

#if v010
#define NODE_API_FUNC( name ) Handle<Value> name ( const Arguments &args )
#else
#define NODE_API_FUNC( name ) void name ( const FunctionCallbackInfo<Value> &args )
#endif
#define NODE_API_FUNC(name) void name(const FunctionCallbackInfo<Value> &args)
Loading