You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
[MSSQL]DataTypes.STRING should be Varchar or NVarchar ? #6036
@komeilshahmoradi check out this issue #8533 might help guide you on how to extend data types to your liking. I am not sure why SequelizeJS decided to opt for nvarchar but it is, in my opinion, incorrect. I'll ask the team and see why this decision was made and what are our options for the future.
Alternatively, if you don't mind using varchar(255) you can use ENUM but this isn't really ideal
I have the same problem. I need to use varchar instead of nvarchar. I execute raw queries through sequelize. The replacements always converts to nvarchar and it is a performance bottleneck for my operation. The regular query with varchar runs in under a second and the one with nvarchar runs anywhere from 30 to 45 seconds.
I tried overriding the tosql() method, but I couldn't get the extended version to be used in the program. Any help on that is much appreciated.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂
Above code executing following query select [uuid],[path] from [omn].[file] where [path] like N'%abc%'
which is taking around 7sec to complete the query. But if I execute the same query by removing 'N' from the query I am getting the same response within 1sec.
I don't want to change what DataTypes.STRING produces, even in a SemVer MAJOR release, because it would make migrating too difficult. But I would like to deprecate DataTypes.STRING, see #14259
In the meantime, there is a workaround you can use that we just documented. You can use VARCHAR like this in mssql:
As for generating 'string' instead of N'string', it will need to wait until we have DataTypes.VARCHAR & DataTypes.VARCHAR.N so we can generate the appropriate string based on the DataType. This part will be tracked in #9107
IF OBJECT_ID('[Users]', 'U') IS NOT NULL DROP TABLE [Users];
IF OBJECT_ID('[Users]', 'U') IS NULL CREATE TABLE [Users] ([id] INTEGER NOT NULL IDENTITY(1,1) , [firstName] VARCHAR(50) NULL, [createdAt] DATETIMEOFFSET NOT NULL, [updatedAt] DATETIMEOFFSET NOT NULL, PRIMARY KEY ([id]));
EXEC sys.sp_helpindex @objname = N'[Users]';
SELECT [uuid], [path], [createdAt], [updatedAt] FROM [File] AS [File] WHERE [File].[path] LIKE N'%-1001_1101.xml' ORDER BY [File].[uuid] OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY
The issue is with the N char after like in query. How to fix this?
@nareshy-quisitive That part is tracked over here #9107 but we won't be able to do that until we have a proper non-n varchar type, which I opened a RFC for here #14259
Activity
janmeier commentedon Jun 7, 2016
sequelize/lib/dialects/mssql/data-types.js
Line 48 in 16b39c6
komeilshahmoradi commentedon Dec 24, 2018
version 4.42.0
I still have this problem
please, how to solve this problem ?
durango commentedon Dec 31, 2018
@komeilshahmoradi check out this issue #8533 might help guide you on how to extend data types to your liking. I am not sure why SequelizeJS decided to opt for
nvarcharbut it is, in my opinion, incorrect. I'll ask the team and see why this decision was made and what are our options for the future.Alternatively, if you don't mind using
varchar(255)you can useENUMbut this isn't really idealsequelize/lib/dialects/mssql/data-types.js
Line 175 in 16b39c6
Reopening because it is an issue
bjagadeesan commentedon Jan 22, 2019
version: 4.42.0
I have the same problem. I need to use varchar instead of nvarchar. I execute raw queries through sequelize. The replacements always converts to nvarchar and it is a performance bottleneck for my operation. The regular query with varchar runs in under a second and the one with nvarchar runs anywhere from 30 to 45 seconds.
I tried overriding the tosql() method, but I couldn't get the extended version to be used in the program. Any help on that is much appreciated.
Below is the code .
But ideally, adding an option to choose between nvarchar and varchar will be much helpful.
stale commentedon Apr 22, 2019
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂
SheTechie commentedon Jun 3, 2021
I am using "sequelize": "^5.21.5"
And still this issue causing a major impact on our operations.
nareshy-quisitive commentedon Mar 18, 2022
Any update on this issue? Its impacting application performace.
WikiRik commentedon Mar 18, 2022
@ephys I think you can answer this
nareshy-quisitive commentedon Mar 18, 2022
Issue is
Above code executing following query
select [uuid],[path] from [omn].[file] where [path] like N'%abc%'which is taking around 7sec to complete the query. But if I execute the same query by removing 'N' from the query I am getting the same response within 1sec.
Note: path is varchar data type in MSSQL DataBase
ephys commentedon Mar 18, 2022
I don't want to change what
DataTypes.STRINGproduces, even in a SemVer MAJOR release, because it would make migrating too difficult. But I would like to deprecateDataTypes.STRING, see #14259In the meantime, there is a workaround you can use that we just documented. You can use
VARCHARlike this in mssql:As for generating
'string'instead ofN'string', it will need to wait until we haveDataTypes.VARCHAR&DataTypes.VARCHAR.Nso we can generate the appropriate string based on the DataType. This part will be tracked in #9107nareshy-quisitive commentedon Mar 24, 2022
@ephys suggestions are not working. We are using the 5.22.4 version. Do we need to upgrade this to the latest version?
ephys commentedon Mar 24, 2022
I did a quick test in a SSCCE running with mssql and the following code:
Which resulted in the following SQL:
I was running it using Sequelize 6, it may be the case that this is not supported in Sequelize 5. There is a small number of breaking changes in Sequelize 6, I definitely recommend upgrading: https://sequelize.org/master/manual/upgrade-to-v6.html
nareshy-quisitive commentedon Apr 12, 2022
I have tested this with the latest version
6.18.0. still facing the same issuehere is my test model class
and i am using this model as
This is producing following query
The issue is with the N char after like in query. How to fix this?
ephys commentedon Apr 12, 2022
@nareshy-quisitive That part is tracked over here #9107 but we won't be able to do that until we have a proper non-n varchar type, which I opened a RFC for here #14259