Skip to content
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
8 changes: 7 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
module.exports = { "extends": "airbnb-base" };
module.exports = {
"extends": "airbnb-base",
rules:{
"linebreak-style": 0,
"no-console": 0
}
};
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,14 @@ sandbox
core
oldtest
.env
.vscode/
.vscode/
.history

build
build/*

*.log
*.tmp
tmp.*
0.*
1.*
66 changes: 66 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
project (odbc)
cmake_minimum_required(VERSION 3.10)

message( STATUS "VOID pointer size = " ${CMAKE_SIZEOF_VOID_P} )

# if(CMAKE_SIZEOF_VOID_P EQUAL 8)
# # 64 bits
# elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
# # 32 bits
# endif()

# To set platform specific LIBS
if(LINUX)
set( LINK_LIBS )
elseif(WIN32)
set( LINK_LIBS odbc32.lib odbccp32.lib )
else()
set( LINK_LIBS )
endif()

# let us print the LINK_LIBS we set for debug purpus only
message( STATUS "LINK_LIBS = " ${LINK_LIBS} )

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(module_include_dir "${PROJECT_SOURCE_DIR}/src")
set(module_source_dir "${PROJECT_SOURCE_DIR}/src")

# Include N-API wrappers
execute_process(COMMAND node -p "require('node-addon-api').include"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE NODE_ADDON_API_DIR
)
string(REPLACE "\n" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR})
string(REPLACE "\"" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR})
include_directories(${CMAKE_JS_INC})

file(GLOB SOURCE_FILES
"${module_include_dir}/dynodbc.h"
"${module_include_dir}/odbc.h"
"${module_include_dir}/odbc_connection.h"
"${module_include_dir}/odbc_statement.h"
"${module_include_dir}/strptime.h"
"${module_source_dir}/dynodbc.cpp"
"${module_source_dir}/odbc.cpp"
"${module_source_dir}/odbc_connection.cpp"
"${module_source_dir}/odbc_statement.cpp"
)

add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${CMAKE_JS_SRC} )
target_include_directories(${PROJECT_NAME}
PUBLIC
${PROJECT_SOURCE_DIR}/src/include
PRIVATE
${NODE_ADDON_API_DIR}
${CMAKE_JS_INC}
)

set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_compile_definitions(${PROJECT_NAME} PRIVATE _CRT_SECURE_NO_WARNINGS=1 NAPI_DISABLE_CPP_EXCEPTIONS)
target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB} ${LINK_LIBS} )

# Define NAPI_VERSION
add_definitions(-DNAPI_VERSION=3)
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,32 @@ When all these steps have been completed, install `node-odbc` into your Node.js
```bash
npm install odbc
```

## Local build with CMake

##### local build prerequisite
- [node.js](https://nodejs.org/en/) (v10 or higher)
- [CMake](https://cmake.org/) (v3.10 or higher)
- [cmake.js](https://github.com/cmake-js/cmake-js) (v6 or higher)

```bash
# To start the build
cd node-odbc

cmake-js build
# or
cmake-js build --debug

# build using Visual Studio
cmake-js -G "Visual Studio 15 2017 Win64"
cmake-js -G "Visual Studio 16 2019" -A x64
cmake-js -G "Visual Studio 16 2019" -A ARM
cmake-js -G "Visual Studio 16 2019" -A ARM64

# FYI: cmake-js can be installed by using
npm install -g cmake-js
```

---

## Important Changes in 2.0
Expand Down
2 changes: 1 addition & 1 deletion src/odbc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ Napi::Array ODBC::ProcessDataForNapi(Napi::Env env, QueryData *data) {

delete storedRow[j].data;
}
rows.Set(i, row);
rows.Set( (uint32_t)i, row);
}

storedRows->clear();
Expand Down
2 changes: 1 addition & 1 deletion src/odbc_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ class CallProcedureAsyncWorker : public Napi::AsyncWorker {
data->sqlReturnCode = ODBC::RetrieveResultSet(data);
ASYNC_WORKER_CHECK_CODE_SET_ERROR_RETURN(data->sqlReturnCode, SQL_HANDLE_STMT, data->hSTMT, "QueryAsyncWorker::Execute", "ODBC::RetrieveResultSet");

data->parameterCount = data->storedRows.size();
data->parameterCount = (SQLSMALLINT)data->storedRows.size();
if (data->bindValueCount != (SQLSMALLINT)data->storedRows.size()) {
SetError("[Node.js::odbc] The number of parameters in the procedure and the number of passes parameters is not equal.");
return;
Expand Down