Skip to content

Error while retrieving select results [TypeError: Cannot read property 'useUTC' of undefined] - test case included #291

Closed

Description

@lafar6502

Hi, I have found a strange error when retrieving select results. The error happens only when I select all the columns of the test table - if you select a subset of these columns there's no error. I think it's not linked to any particular data type as I didn't find any column that would cause the problem alone.

Environment:

MS SQL Server Express 12.0.2269.0
nodejs v0.12.2
[email protected] node_modules\tedious
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected], [email protected], string_dec
[email protected], [email protected], [email protected], [email protected])
└── [email protected] ([email protected])
Windows 8 64 bit

The error is

TypeError: Cannot read property 'useUTC' of undefined
typeerror: Cannot read property 'useUTC' of undefined
    at callee$0$0$ (C:\devs\unitech\terminal_nw\node_modules\tedious\lib\value-p
arser.js:498:70)
    at tryCatch (C:\devs\unitech\terminal_nw\node_modules\tedious\node_modules\b
abel-runtime\regenerator\runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (C:\devs\unitech\terminal_
nw\node_modules\tedious\node_modules\babel-runtime\regenerator\runtime.js:315:22
)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\d
evs\unitech\terminal_nw\node_modules\tedious\node_modules\babel-runtime\regenera
tor\runtime.js:100:21)
    at tryCatch (C:\devs\unitech\terminal_nw\node_modules\tedious\node_modules\b
abel-runtime\regenerator\runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (C:\devs\unitech\terminal_
nw\node_modules\tedious\node_modules\babel-runtime\regenerator\runtime.js:261:24
)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\d
evs\unitech\terminal_nw\node_modules\tedious\node_modules\babel-runtime\regenera
tor\runtime.js:100:21)
    at tryCatch (C:\devs\unitech\terminal_nw\node_modules\tedious\node_modules\b
abel-runtime\regenerator\runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (C:\devs\unitech\terminal_
nw\node_modules\tedious\node_modules\babel-runtime\regenerator\runtime.js:261:24
)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\d
evs\unitech\terminal_nw\node_modules\tedious\node_modules\babel-runtime\regenera
tor\runtime.js:100:21)

Test script that reproduces the error:

var td = require('tedious');

var cfg = {
    userName: 'zewil',
    password: 'PASS',
    server: 'WYPAS3',
    options: {database: 'testdb', useUTC: true}
};

var cn = new td.Connection(cfg);
console.log('connecting');
cn.on('connect', function(err) {
    if (err) {
        console.log('connection error', arguments);
        process.exit();
    }
    console.log('connected - OK');
    var sql = "SELECT [Id],[OrderDate],[TotalNr] ,[ClientId], ClientName, Amount, ArtNr, ProductGroup from TestTable";
    var rq = new td.Request(sql, function(err, rows) {
        if (err) {
            console.log('request error', arguments);
            process.exit();
        };
        console.log('request executed, rows: ', rows);
    });
    var cnt = 0;
    rq.on('row', function(r) {
        cnt++;
        console.log('got row', cnt);
    });
    cn.execSql(rq);
});

and finally, test table creation script:

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TestTable](
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [OrderDate] [datetime] NULL,
    [TotalNr] [int] NULL,
    [ClientId] [int] NULL,
    [ClientName] [nvarchar](50) NULL,
    [Amount] [float] NULL,
    [ArtNr] [nvarchar](50) NULL,
    [ProductGroup] [nvarchar](50) NULL
) ON [PRIMARY]

GO
SET IDENTITY_INSERT [dbo].[TestTable] ON 

GO
INSERT [dbo].[TestTable] ([Id], [OrderDate], [TotalNr], [ClientId], [ClientName], [Amount], [ArtNr], [ProductGroup]) VALUES (40573, NULL, NULL, 123, N'some client', 1, N'ABC123', NULL)
GO
INSERT [dbo].[TestTable] ([Id], [OrderDate], [TotalNr], [ClientId], [ClientName], [Amount], [ArtNr], [ProductGroup]) VALUES (40584, CAST(N'2015-07-09 00:00:00.000' AS DateTime), NULL, 67, N' SPRINTER W RADZIEWICZS ŁEPE G BIALIC M BOBA', 3, N'bb34567c', NULL)
GO
INSERT [dbo].[TestTable] ([Id], [OrderDate], [TotalNr], [ClientId], [ClientName], [Amount], [ArtNr], [ProductGroup]) VALUES (40585, CAST(N'2015-07-31 00:00:00.000' AS DateTime), NULL, 66, N'RAFAŁ ANTOSZAK Przedsiębiorstwo H-U "ANMAR"', 1, N'aaaaa', NULL)
GO
INSERT [dbo].[TestTable] ([Id], [OrderDate], [TotalNr], [ClientId], [ClientName], [Amount], [ArtNr], [ProductGroup]) VALUES (40574, NULL, NULL, 123, N'some client', 1, N'ABC123', NULL)
GO
INSERT [dbo].[TestTable] ([Id], [OrderDate], [TotalNr], [ClientId], [ClientName], [Amount], [ArtNr], [ProductGroup]) VALUES (40575, CAST(N'2015-07-30 21:58:59.807' AS DateTime), NULL, 123, N'some client', 1, N'ABC123', NULL)
GO
INSERT [dbo].[TestTable] ([Id], [OrderDate], [TotalNr], [ClientId], [ClientName], [Amount], [ArtNr], [ProductGroup]) VALUES (40576, CAST(N'2015-07-30 22:02:19.510' AS DateTime), NULL, 123, N'some client', 1, N'ABC123', NULL)
GO
INSERT [dbo].[TestTable] ([Id], [OrderDate], [TotalNr], [ClientId], [ClientName], [Amount], [ArtNr], [ProductGroup]) VALUES (40577, CAST(N'2015-07-30 22:02:22.173' AS DateTime), NULL, 123, N'some client', 1, N'ABC123', NULL)
GO
INSERT [dbo].[TestTable] ([Id], [OrderDate], [TotalNr], [ClientId], [ClientName], [Amount], [ArtNr], [ProductGroup]) VALUES (40578, CAST(N'2015-07-30 23:38:44.560' AS DateTime), NULL, 123, N'some client', 1, N'ABC123', NULL)
GO
INSERT [dbo].[TestTable] ([Id], [OrderDate], [TotalNr], [ClientId], [ClientName], [Amount], [ArtNr], [ProductGroup]) VALUES (40572, CAST(N'2015-01-01 00:00:00.000' AS DateTime), 103002, NULL, N'Nerli', 2, N'123', N'Screen')
GO
SET IDENTITY_INSERT [dbo].[TestTable] OFF
GO

Activity

  1. lafar6502 commented on Aug 1, 2015

    @lafar6502
    Author

    UPDATE
    just one row in this table is enough to repeat the issue:

    INSERT [dbo].[TestTable] ([Id], [OrderDate], [TotalNr], [ClientId], [ClientName], [Amount], [ArtNr], [ProductGroup]) VALUES (40578, CAST(N'2015-07-30 23:38:44.560' AS DateTime), NULL, 123, N'some client', 1, N'ABC123', NULL)
    

    and BTW my timezone is Poland (CEST) - in case this is some timezone issue.

  2. arthurschreiber commented on Aug 1, 2015

    @arthurschreiber
    Collaborator

    Ha, this is an issue I seem to have introduced with #285 in the 0.12.0 release. Let me fix that up and push a new release.

  3. added a commit that references this issue on Aug 1, 2015
    175d28d
  4. arthurschreiber commented on Aug 1, 2015

    @arthurschreiber
    Collaborator

    I prepared 1.12.1 over at #292. As soon as the travis and appveyor builds finish succesfully, I'll push out a new release.

    I'm really sorry about causing this problem for you. Some areas of the tedious codebase are not covered by our unit or integration tests, which causes issues like this to creep up. I'll make it a priority to extend the coverage in the future to keep another problem like this from happening.

  5. added a commit that references this issue on Aug 1, 2015
    2ae96e0
  6. arthurschreiber commented on Aug 1, 2015

    @arthurschreiber
    Collaborator

    I just pushed 1.12.1. Please try that version.

  7. lafar6502 commented on Aug 1, 2015

    @lafar6502
    Author

    Looks promising - error is gone in my test case. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions