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

Unable to find dialect at msnodesqlv8/lib/sequelize #325

Open
LightsLegend7276 opened this issue Apr 19, 2024 · 7 comments
Open

Unable to find dialect at msnodesqlv8/lib/sequelize #325

LightsLegend7276 opened this issue Apr 19, 2024 · 7 comments

Comments

@LightsLegend7276
Copy link

I am trying to get this working with sequelize at work. We are on VMs and am not sure if that may be causing an issue, but when I tried the example at home I was at least able to get passed this error. While at work I can't get passed this error. We are using msnodesqlv8 v3.1.0 and sequelize v6.29.0. It is failing inside of lib/sequelize/connection.js at this import statement:
const mssql = require('msnodesqlv8')
Any help here would be greatly appreciated.

@TimelordUK
Copy link
Owner

i no longer have the time to dedicate to this project,

I did update https://github.com/TimelordUK/msnodesqlv8-sequelize to latest version - this is using typescript

i will try and write a similar javascript example

but if i clone rep

npm run install
npm run build
npm run app
> msnodesqlv8-sequelize@1.0.0 app
> node ./dist/demo.js

Executing (d59c9ce7-f4ee-41ba-aa79-c9fcb1d8b2b9): IF OBJECT_ID('[users]', 'U') IS NOT NULL DROP TABLE [users];
Executing (d59c9ce7-f4ee-41ba-aa79-c9fcb1d8b2b9): 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 (d59c9ce7-f4ee-41ba-aa79-c9fcb1d8b2b9): EXEC sys.sp_helpindex @objname = N'[users]';
Executing (d59c9ce7-f4ee-41ba-aa79-c9fcb1d8b2b9): INSERT INTO [users] ([username],[job],[createdAt],[updatedAt]) OUTPUT INSERTED.[id],INSERTED.[username],INSERTED.[job],INSERTED.[createdAt],INSERTED.[updatedAt] VALUES (@0,@1,@2,@3);
Executing (d59c9ce7-f4ee-41ba-aa79-c9fcb1d8b2b9): INSERT INTO [users] ([username],[job],[createdAt],[updatedAt]) OUTPUT INSERTED.[id],INSERTED.[username],INSERTED.[job],INSERTED.[createdAt],INSERTED.[updatedAt] VALUES (@0,@1,@2,@3);
Executing (d59c9ce7-f4ee-41ba-aa79-c9fcb1d8b2b9): INSERT INTO [users] ([username],[job],[createdAt],[updatedAt]) OUTPUT INSERTED.[id],INSERTED.[username],INSERTED.[job],INSERTED.[createdAt],INSERTED.[updatedAt] VALUES (@0,@1,@2,@3);
Executing (d59c9ce7-f4ee-41ba-aa79-c9fcb1d8b2b9): SELECT [id], [username], [job], [createdAt], [updatedAt] FROM [users] AS [user] WHERE [user].[id] = 3;
{
    "id": 3,
    "username": "techno03",
    "job": "Agile Leader",
    "createdAt": "2024-04-20T10:16:29.973Z",
    "updatedAt": "2024-04-20T10:16:29.973Z"
}
Executing (d59c9ce7-f4ee-41ba-aa79-c9fcb1d8b2b9): 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": "2024-04-20T10:16:29.973Z",
    "updatedAt": "2024-04-20T10:16:29.973Z"
}
const Sequelize = require('sequelize')
const connectionString = 'Driver={ODBC Driver 18 for SQL Server}; Server=DESKTOP-VIUCH90;UID=linux; PWD=linux; Database=node;Encrypt=no;'

const sequelize = new Sequelize({
  dialect: 'mssql',
  dialectModulePath: 'msnodesqlv8/lib/sequelize',
  dialectOptions: {
    user: '',
    password: '',
    database: 'node',
    options: {
      driver: '',
      connectionString,
      trustedConnection: true,
      instanceName: ''
    }
  },
  pool: {
    min: 0,
    max: 5,
    idle: 10000
  }
})

function createUserModel () {
  return sequelize.define('user', {
    username: {
      type: Sequelize.STRING
    },
    job: {
      type: Sequelize.STRING
    }
  })
}

@LightsLegend7276
Copy link
Author

I was able to get it working on my home computer, but within my organization it won't work. I thought maybe there was some dependency conflict so I tried just the example project, but that too failed for the same reason. Within our org we have two drives that mirror each other, so when I am in vscode it shows that there is a conflict in the msnodesqlv8 module because it sees both files.. I'm not sure if that is the issue or if that is just some eslint error, but it's the only module it's happening on even though everything is replicated on both drives. I am going to try clearing my npm cache, deleting project from both drives and recreating in a drive that doesn't replicate to see if it works when I am next at work.

@LightsLegend7276
Copy link
Author

Hi @TimelordUK, hoping you can point me in the right direction here. I think I tracked down the issue. When running the project at home I have a build directory with msnodesqlv8 that util.js requires. Within our org we don't for some reason. Could you let me know how this directory is created. Does it have something to do with gyp? I read through the read me about some pre compiled binaries based on node version and if it doesn't have it we can run node gyp to create our own for the version of node we are using. At home I'm on node v 21.7.3. At work we are on v18.18.0. So when I tried running the node-gyp command our org blocks since it attempting to go out externally to node site to download v18.18.0 tar file. Any help here would be greatly appreciated.

@TimelordUK
Copy link
Owner

Yes this is related to node gyp. If you go to the releases page you should see all the binaries attached to the release. As part of the install it is absolutely required to either download or compile the sec code into a shared library that is loaded by node. The javascript is a fairly thin wrapper around the cpp which talks to ODBC.

Really it is not recommended to build the code unless necessary and you have someone to hand whom can configure the compiler as it would need build kit from visual studio on windows. On Linux the system compiler would probably work but then you would need ODBC dev headers installed.

Can you download the correct tar manually from Release page in git and unpack it by hand into build/Release folder.

Failing that I’m afraid a sus admin is going to have to at least do that step the library has no chance of working without the compiler code installed alongside javascript.

@LightsLegend7276
Copy link
Author

Hi @TimelordUK, thanks for getting back to me. I was able to get it working locally in my org now by unpacking the tar. But that's on a WIndows VSI. We'd also now have to figure out to get everything done on linux. My only question is why do the pre compiled binaries get built on my home computer without all of these extra steps, but not within our org. Could it be because we are using an older version of this library? We only have up to 3.1.0 available to us and working on node v20.10.

@TimelordUK
Copy link
Owner

They are not being built on your home pc. The firewall in your org seems to prevent the installation of going to the release page and downloading the correct binary and installing it. This step works at home and. It within organisation. Failing that the library tries to build the src code locally but that as stated requires the compiler and header files. Your only remaining course of action is to manually install binary yourself.

@LightsLegend7276
Copy link
Author

Understood, I was a bit confused here since the pre built script stuff is pretty new to me. Thanks for your time.

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