-
Notifications
You must be signed in to change notification settings - Fork 43
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
Compatibility with sequelize v5/v6 #159
Comments
Sorry I am still not sure what needs to be done to make this work again ? |
The easiest (but dirty) way is to add a line like this to the constructor of Connection in lib/sequelize/connection.js: this.STATE = {INITIALIZED: 1} Within sequelize, the following code is executed: const connection = new this.lib.Connection(connectionConfig);
if (connection.state === connection.STATE.INITIALIZED) {
connection.connect();
} This will not throw an error then and will compare The more comprehensive way would be
|
thanks for letting me know the fix - I went with the simple solution for now should be fixed in latest version 1.1.7 "dev\js\sql\node_modules\msnodesqlv8\samples\javascript\sequelize.js
Executing (1c5937d5-fbba-4665-b2d9-2bf852cc487c): IF OBJECT_ID('[users]', 'U') IS NOT NULL DROP TABLE [users];
Executing (1c5937d5-fbba-4665-b2d9-2bf852cc487c): IF OBJECT_ID('[users]', 'U') IS NULL CREATE TABLE [users] ([id] INTEGER NOT NULL IDENTITY(1,1) , [username] NVARCHAR(255) NULL, [job] NVARCHAR(255) NULL, [createdAt] DATETIMEOFFSET NOT NULL, [updatedAt] DATETIMEOFFSET NOT NULL, PRIMARY KEY ([id]));
Executing (1c5937d5-fbba-4665-b2d9-2bf852cc487c): EXEC sys.sp_helpindex @objname = N'[users]';
Executing (1c5937d5-fbba-4665-b2d9-2bf852cc487c): INSERT INTO [users] ([username],[job],[createdAt],[updatedAt]) OUTPUT INSERTED.[id],INSERTED.[username],INSERTED.[job],INSERTED.[createdAt],INSERTED.[updatedAt] VALUES (@0,@1,@2,@3);
Executing (ad3decdb-8914-44c4-a58c-eb3908c7f6ad): INSERT INTO [users] ([username],[job],[createdAt],[updatedAt]) OUTPUT INSERTED.[id],INSERTED.[username],INSERTED.[job],INSERTED.[createdAt],INSERTED.[updatedAt] VALUES (@0,@1,@2,@3);
Executing (f2b32239-e8e9-4fb3-a767-beee06d6b49c): INSERT INTO [users] ([username],[job],[createdAt],[updatedAt]) OUTPUT INSERTED.[id],INSERTED.[username],INSERTED.[job],INSERTED.[createdAt],INSERTED.[updatedAt] VALUES (@0,@1,@2,@3);
Executing (f2b32239-e8e9-4fb3-a767-beee06d6b49c): SELECT [id], [username], [job], [createdAt], [updatedAt] FROM [users] AS [user] WHERE [user].[id] = 3;
{
"id": 3,
"username": "techno03",
"job": "Agile Leader",
"createdAt": "2020-07-05T14:17:54.670Z",
"updatedAt": "2020-07-05T14:17:54.670Z"
}
Executing (f2b32239-e8e9-4fb3-a767-beee06d6b49c): SELECT [id], [username], [job], [createdAt], [updatedAt] FROM [users] AS [user] WHERE [user].[job] = N'Agile Leader' ORDER BY [user].[id] OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY;
{
"id": 3,
"username": "techno03",
"job": "Agile Leader",
"createdAt": "2020-07-05T14:17:54.670Z",
"updatedAt": "2020-07-05T14:17:54.670Z"
}
Executing (f2b32239-e8e9-4fb3-a767-beee06d6b49c): SELECT [id], [username], [job], [createdAt], [updatedAt] FROM [users] AS [user];
[
{
"id": 1,
"username": "techno01",
"job": "Programmer",
"createdAt": "2020-07-05T14:17:54.669Z",
"updatedAt": "2020-07-05T14:17:54.669Z"
},
{
"id": 2,
"username": "techno02",
"job": "Head Programmer",
"createdAt": "2020-07-05T14:17:54.670Z",
"updatedAt": "2020-07-05T14:17:54.670Z"
},
{
"id": 3,
"username": "techno03",
"job": "Agile Leader",
"createdAt": "2020-07-05T14:17:54.670Z",
"updatedAt": "2020-07-05T14:17:54.670Z"
}
]
Executing (f2b32239-e8e9-4fb3-a767-beee06d6b49c): SELECT count(*) AS [count] FROM [users] AS [user] WHERE [user].[job] LIKE N'%Programmer';
Executing (1c5937d5-fbba-4665-b2d9-2bf852cc487c): SELECT [id], [username], [job], [createdAt], [updatedAt] FROM [users] AS [user] WHERE [user].[job] LIKE N'%Programmer' ORDER BY [user].[id] OFFSET 0 ROWS FETCH NEXT 2 ROWS ONLY;
2
[
{
id: 1,
username: 'techno01',
job: 'Programmer',
createdAt: 2020-07-05T14:17:54.669Z { nanosecondsDelta: 0 },
updatedAt: 2020-07-05T14:17:54.669Z { nanosecondsDelta: 0 }
},
{
id: 2,
username: 'techno02',
job: 'Head Programmer',
createdAt: 2020-07-05T14:17:54.670Z { nanosecondsDelta: 0 },
updatedAt: 2020-07-05T14:17:54.670Z { nanosecondsDelta: 0 }
}
]
Executing (1c5937d5-fbba-4665-b2d9-2bf852cc487c): UPDATE [users] SET [job]=@0,[updatedAt]=@1 WHERE [id] = @2
[ 0 ]
done
|
sequelize adapted to the tedious api and is now checking a
connection.state
versus aconnection.STATE.INITIALIZED
property. If those match, the.connect()
function is called.See sequelize/sequelize#12182 (comment)
Since the guys from sequelize won't fix that code so it would still work with msnodesqlv8, this module needs to be adapted.
In the first place, the
.INITIALIZED
enum needs to be defined. Otherwise, this will lead to an uncaught exception. As for the current implementation, the if statement should not return true since the .connect() should not be called sync, but it is called from the constructor after the driver has been detected.I could add a dummy STATE if this is desired...
The text was updated successfully, but these errors were encountered: