Skip to content


Subversion checkout URL

You can clone with
Download ZIP
branch: master
Commits on Jul 23, 2013
  1. @jkint

    Merge pull request #122 from cravergara/patch-1

    jkint authored
    cast OnForeground to uv_after_work_cb
Commits on May 22, 2013
  1. @mathewc @jkint

    Fix bug for connection is null closing failure

    mathewc authored jkint committed
    When a connection fails to open, check for null on the returned
    connection before attempting to close it.
    Adding a test for connection failure handling
Commits on Mar 30, 2013
  1. @cravergara

    cast OnForeground to uv_after_work_cb

    cravergara authored
    Without this directive, compilation fails with node 0.10.x
Commits on Mar 20, 2013
  1. @jkint

    Connections closed when an error occurs using sql.query or sql.queryRaw

    jkint authored
    When sql.query or sql.queryRaw were called and an error occurred during
    processing, the connection was not closed and would stay open for several
    minutes until collected.  Now the connections are closed immediately.
    Also added a try/catch around a user's callback for query and queryRaw so
    if an exception is thrown, the connection is closed.  The exception is
    then rethrown with additional information.
    The try/catch will be upgraded to use domains in the near future.
    Fixes #121
  2. @jkint

    Connection is not closed prematurely until a query is complete

    jkint authored
    Closing a connection explicitly would close the connection immediately
    rather than wait until ongoing operations were complete on that
    connection.  The close operation now waits until all other operations
    are finished.
    Since there are legitimate times to forcibly close the connection
    immediately, a new (optional) flag has been added to the close call:
    conn.close( immediately, callback )
    If the immediately parameter is supplied and is true, then the
    connection will be closed rather than waiting for pending
    operations/queries.  Note: if immediately is supplied but is not a
    boolean, then an error is thrown.
    close can still be called with either nothing or a callback as before.
    Tests added to verify the new parameter.
    Fixes #32
  3. @jkint

    Closed connection throws exception on further access

    jkint authored
    When a connection is closed, the connection object throws errors
    when another method is called on that connection object.
    Added a test to verify that the exceptions occur when a connection
    is closed and another method is called.
    Fixes #32
Commits on Mar 1, 2013
  1. @jkint

    UDT metadata mistakenly returns type of 'text'

    jkint authored
    The column values returned to callbacks are Buffers, so the metadata
    should properly reflect that by returning 'binary' as the metadata
    Test updated to verify fix.
    Fixes #117
Commits on Feb 27, 2013
  1. @jkint

    Return the SQL Server data type and UDT classname in the metadata

    jkint authored
    Added a new field to the metadata, sqlType, that returns the datatype
    as given by SQL Server (e.g., "varchar", "bigint", etc.)
    When this type is "udt", an additional field, "udtType" is added that
    contains the class name for the UDT type.  This can be used to see if
    the type is a spatial type (e.g. "geography").
    Also contain minor whitespace corrections (tabs to spaces).
    Tests were updated to reflect the change.
  2. @jkint

    Buffers JS objects now accepted as input parameters

    jkint authored
    They are bound as varbinary parameters.
    Since Buffer object buffers are managed by V8 directly, we don't delete them as we
    do other parameters we've copied.
    Consolidated some error message code for parameters into a single function.
    Added a small unit test to verify Buffers are being inserted correctly.
    Also removed comments and minor code clean up.
Commits on Jan 24, 2013
  1. @jkint

    Fixed: Date at end of a year trips an assert

    jkint authored Jay Kint committed
    When a date was near the end of a year before 1970, an assert would
    trip because the day would be out of range of 0 to 30 (0 based day
    within the month).
    The day would be off because the time was being calculated after the
    year was calculated from the day.  Moving this calculation forward
    solved the problem.
    Added a test to guard against regression.
Commits on Jan 12, 2013
  1. @jkint

    Fixed: Dates before 1970 with time of midnight incorrectly inserted

    jkint authored
    This is especially onerous because the default time for a date is midnight.
    Tests have been added to verify that dates with a time of midnight are
    inserted and retrieved correctly.
    Fixes #85
    Fixes #103
  2. @jkint

    Visual C++ 2012 (Express) compile support

    jkint authored
    Added <memory> for shared_ptr and unique_ptr support in Visual C++ 2012.
    Thanks to Brian-Cole for diagnosing this.
    Fixes #99
Commits on Jan 8, 2013
  1. @jkint

    npm install - no compilation required

    jkint authored
    Currently when using npm, sqlserver.node must be created by compiling the
    extension with node-gyp.
    This commit adds an installation script that downloads the appropriate
    sqlserver.node file from Microsoft at installation time.
    Supports node.js 0.6.x and 0.8.x versions on ia32 and x64 Windows.
Commits on Oct 17, 2012
  1. @jkint
  2. @jkint

    Merge pull request #84 from DMGambone/Error-with-node-inspector-fix

    jkint authored
    Fix for issue #62 - Debugging query callback with node-inspector!
Commits on Oct 16, 2012
  1. @jguerin
  2. @DMGambone

    Fix for issue #62 - Debugging query callback with node-inspector!

    DMGambone authored
    Per the comments from clintwood, the original line:
    callback->Call(Undefined().As<Object>(), argc, args);
    causes node-inspector to crash if breakpoints are added in any query
    callback function.  This change corrects that.
Commits on Oct 12, 2012
  1. @jkint

    Merge release branch v0.2 into master

    jkint authored
    Master is now the main development branch for msnodesql.
  2. @jguerin @jkint

    Release readiness

    jguerin authored jkint committed
    Updated README with link to contribution guidelines.
    Added contribution guidelines.
    Updated package.json with new name, version and other minor things.
    Added ignore for Mac .DS_store files.
  3. @jkint

    Change name from node-sqlserver to msnodesql

    jkint authored
    Changed error messages to reflect the new name of the component.
    Microsoft Internal Review Id jaykint-f6a2a73d0d204995bf07cc87c80a74ac
  4. @jkint

    Fix default date used for time columns

    jkint authored
    When a time column is retrieved and converted to a Date object, SQL
    Server's default date of 1900-1-1 is substituted for the missing
    components since time columns don't have a date.
    However, the constants being used for this were erroneously using JS
    default of 0 as the month rather than 1, the SQL Server default. This
    affected the conversion process and caused certain dates to be
    returned incorrectly.
    Microsoft Internal Review Id jaykint-43ad01c968244ab6a5481cb64ac7d06f
Commits on Oct 9, 2012
  1. @jkint

    Changed array test in parameter validation

    jkint authored
    Since Array.isArray is safer and better, the check was changed from:
    paramsOrCallback instanceof Array
    Array.isArray( paramsOrCallback )
    Microsoft Internal Review Id jaykint-4e4b23c0ae944ce7b9d4b964040032fb
Commits on Oct 4, 2012
  1. @jkint

    Fixed forgotten more flag in sql.query

    jkint authored
    When sql.query is called, the more flag was not being passed properly
    to the user's callback.
    Microsoft Internal Review Id jaykint-863451cd9b9044b0ba50e0f0f39079e0
  2. @jkint

    Match parameter validation expectations

    jkint authored
    The previous parameter validation fix broke certain expectations about
    using null as a valid substitute for the parameter array.
    This fix now allows the use of null as the parameter array in a query
    sql.query( connString, query, null, function( e, r, m ) ... );
    Added cases to the parameter validation test for null.
    Also included a fix for the parameter validation test.  The test now
    verifies that errors were thrown for error cases.
    Microsoft Internal Review Id jaykint-f9fd5dc733d04f859637f8f3ae6066d6
  3. @jkint

    Change 'hang' to 'not respond'

    jkint authored
    Change wording to more neutral context
    Microsoft Internal Review Id jaykint-863451cd9b9044b0ba50e0f0f39079e0
Commits on Sep 27, 2012
  1. @jkint

    Dates before 1970 can now be inserted

    jkint authored
    _gmtime64_s cannot convert dates before Jan 1, 1970.
    Reimplemented gmtime functionality within the TimestampColumn class
    to work for dates before 1970.
    Since this class now contains several non-trivial functions, these
    functions were moved to a source file of their own, Column.cpp.
    Added a simple test to verify the fix, but also did adhoc testing with
    several thousand dates.  These are not added simply because the unit
    tests would take too long to execute.
    Fixes #57
    Microsoft Internal Review Id jaykint-04d9b9b5f8914a7a96d80412120d408d
Commits on Sep 26, 2012
  1. @jkint

    Separate error information

    jkint authored
    When an error was returend, its string contained the sqlstate and
    message concatenated.  Since the sqlstate is often the most useful
    portion of the message, this forced string parsing, an inconvenient
    and expensive operation.
    Also, the native code was missing.  This native code is a number and
    is very precise compared to either sqlstate or messages.
    Error objects returned now contain three pieces of information:
    1) error message as returned by the driver/server
    2) sqlstate key contains the 5 letter/number code of the error
    2) code key is the native error code returned by SQL Server/ODBC
    Fixes #22
    Fixes #45
    Microsoft Internal Review Id jaykint-4cb9e45b9b2c4cee80a775ca6132872c
Commits on Sep 18, 2012
  1. @jkint

    Function parameter validation

    jkint authored
    When a node-sqlserver function is called, mandatory parameters are
    validated for their type.
    The following combinations are valid for query and queryRaw (either
    the module or connection member variety):
    1) sql.query( c, tsql );
    2) sql.query( c, tsql, function( ... ) { ... });
    3) sql.query( c, tsql, [1, 2, 3] );
    4) sql.query( c, tsql, [1, 2, 3], function( ... ) { ... });
    If one of these combinations is not present then an exception is
  2. @jkint

    Retrieve strings with embedded nulls

    jkint authored
    Strings containing null characters are now correctly retrieved from
    SQL Server.  We use lengths instead of relying on C++ library routines
    for strings.  Strings are now contained in std::vectors rather than
    Consolidated the string reading functionality into a new method,
    TryReadString.  Binary columns will also be consolidated into this
    function in the near future.
    Also, removed extraneous allocations and copies when retrieving
    strings.  However, there is still a copy done by V8 when returning the
    value (StringColumn::ToValue).  In the v8.h file there is an
    ExternalStringResource that could potentially be leveraged to even
    avoid this last copy.
    For fixed length string columns only the amount of memory needed is
    allocated rather than always allocating 8k as before.
    For LOB columns, 8k at a time is allocated and returned to the
    Also handle the case when no data is returned
    erroneously (SQL_NO_DATA) by SQLGetData.  Added custom errors for this
    functionality that can be built upon in the future.
    Miscellaneous whitespace additions and cleanup.
    Added resets for current column to 0 when a new row or resultset are
    Added unit tests for strings with embedded nulls.  Added unit tests
    for LOB strings that return multiple packets of data.  Added unit
    tests to test the 8000 byte limit of non LOB strings.
    Microsoft Internal Review Id jaykint-6fe14c61d0814ed384857f9ad505bc3b
Commits on Sep 16, 2012
  1. @jkint

    Remove C++ exceptions and async ODBC calls

    jkint authored
    Removed C++ exceptions and replaced them with checked status codes.
    Sometimes exceptions were not being caught by the catch in
    OdbcOperation::InvokeBackground which caused node.exe to abruptly exit.
    Removed use of ODBC async APIs.  Now ODBC calls are synchronous and
    done in the background using libuv's thread queue.
    These changes have resulted in improved stability and performance.
    Fixes #8
    Microsoft Internal Review Id: jaykint-0ac46d2b903d4439b4f5d509376a0deb
Commits on Sep 11, 2012
  1. @wread

    insert 'null' into 'guid' or 'xml' columns, fetches data as empty str…

    wread authored
    …ing instead of null
    fixes #34
    fixes #36
    Also added new test cases to verify no truncation occurs for:
    1) string with length = max buffer size
    2) string with length = max buffer size + 1
    internal review id wread-19033fb92edc44da9926da3c95edd3d0
Commits on Aug 30, 2012
  1. @jguerin

    Updating Readme to include contribution guidelines

    jguerin authored
    Added information for people wishing to contribute to this project.
Commits on Aug 22, 2012
  1. @jkint

    Parameters now bind properly

    jkint authored
    Until now parameters were being substitued directly into a query.
    Even being quoted, this is subject to injection attacks.
    Now parameters are bound properly using ODBC.
    Also fixed was the reference to ext.queryRaw in sql.js.  There is no
    queryRaw within the native module.  This should have been query.
    Unit tests for parameters added.
    Updated runtests.js script to be compatible with 0.8.x and 0.6.x.
    Fixes #3
    Fixes #9
    Fixes #12
    Fixes #40
    Fixes #47
Commits on Aug 2, 2012
  1. @wread

    New Functional Tests

    wread authored
    This set of changes is intended to augment the existing unit tests in
    an effort to cover a greater range of functionality and to add some
    simple debugging functionality. In an effort to reduce test code
    duplication, there is a group of functions that were placed in a
    common file called �CommonTestFunctions.js�. These functions perform
    simple tasks like creating tables and inserting data, as well as some
    utility tasks like writing debugging messages to help resolve issues.
    The idea behind placing these types of functions in a central place is
    1) if a certain functionality changes, one could allow for
    that change by fixing one area instead of many different areas in all
    the tests.
    2) debugging is easier since the logging functions
    (described in more detail below) can be modified/activated in one
    central location without changing any of the existing tests.
    The following describes the added tests:
    A list of supported SQL Server data types was generated by calling the
    ODBC API SQLGetTypeInfo(SQL_ALL_TYPES). For each of these relevant
    types a test case was created that inserted a null value and a valid
    data value into a column of each type. The data was then retrieved
    into buffers of their corresponding JS data types and then verified.
    Additional test cases were created to ensure batched queries run
    successfully using this driver. The concern here is that the driver
    may not function correctly if one of more of these queries doesn�t
    return a result set. Batched queries of this type included queries
    like �SELECT FROM table; INSERT INTO table; SELECT FROM table;�, or
    �SELECT FROM table; PRINT �this is a message�; SELECT FROM table;�.
    Several negative test cases were added to ensure invalid queries
    failed gracefully and reported the correct error messages.
    The following describes the debugging/logging functionality:
    Two functions were added a common file �CommonTestFunctions.js� which
    hopefully will speed up debugging issues. These are
    �debugComments(Message)� and �errorComments(Message)�.  The intent of
    these is to have a centrally located logging mechanism which can be
    turned on/off by setting the variable �writeDebugComments� to �true�
    or �false�. If a test is hanging or AV�ing, one can quickly find where
    the issue is by setting this variable to �true�. In addition, these
    functions could be easily expanded to write to log files, for example,
    without modifying any of the tests.
    The following describes other changes that were made:
    All tests were updated to work properly against a SQL Azure server.
    (For example, one requirement for SQL Azure is that there is a
    clustered index on its tables.)
    All tests were updated to use a common connection string. This
    modification was made so that changing which SQL Server or database
    used when running of all tests requires updates in only one place.
    Microsoft Internal Review Id: wread-34642987b9f24a48866637268ec500e5
Commits on Jul 26, 2012
  1. @jkint

    Fix connection memory leak

    jkint authored
    This is a response to a memory leak that was witnessed in our stress
    Below is a list of reading that should illuminate this change:
    Basically, we were using a persistent handle to hold a reference to
    ourselves in the Connection class.  This prevented the Collection
    class from being collected properly.  The solution is to use a weak
    persistent handle.
    The node::ObjectWrap class, which the Connection class inherits from,
    is a WeakHandle and manages the lifetime properly, calling the
    destructor (provided it is virtual) of our instance  when it is being
    collected.  A destructor was added to the Connection class that closes
    the ODBC connection if necessary.
    Since there are now two paths into closing a connection, it is
    possible for a race condition to arise.  A critical section has been
    put around the code that disconnects from SQL Server to prevent this.
    For now this critical section code is Windows specific.  It will be
    rewritten as cross platform at a later time.
    Also, we were potentially leaking a persistent handle to the
    OdbcConnection class in the OpenOperation class, meaning that the
    OpenConnection class would never be collected.  To fix this, we call
    the Dispose member function of the persistent handle to notify V8 that
    we no longer need the pointer.
    Microsoft Internal Review Id: jaykint-559c37537fb54de28ea1481d9bdf55cb
Something went wrong with that request. Please try again.