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

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

Closed
lafar6502 opened this issue Aug 1, 2015 · 5 comments

Comments

@lafar6502
Copy link

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
tedious@1.12.0 node_modules\tedious
├── sprintf@0.1.5
├── big-number@0.3.1
├── bl@1.0.0
├── iconv-lite@0.4.11
├── readable-stream@2.0.2 (process-nextick-args@1.0.2, isarray@0.0.1, string_dec
oder@0.10.31, inherits@2.0.1, util-deprecate@1.0.1, core-util-is@1.0.1)
└── babel-runtime@5.8.20 (core-js@1.0.1)
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
@lafar6502
Copy link
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.

@arthurschreiber
Copy link
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.

arthurschreiber added a commit that referenced this issue Aug 1, 2015
This issue was introduced with the refactoring that happened in #285.
@arthurschreiber
Copy link
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.

@arthurschreiber
Copy link
Collaborator

I just pushed 1.12.1. Please try that version.

@lafar6502
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants