-
Notifications
You must be signed in to change notification settings - Fork 283
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
add MS SQL Server dialect. #595
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Igal doing the lord's work right here, thank you so much. |
Often these sql servers are hosted in azure. Put any thought into authentication using azure active directory? Maybe a dumb question. import * as dotenv from 'dotenv';
import sql from 'mssql';
dotenv.config({ path: `.env.${process.env.NODE_ENV}`, debug: true });
const server = process.env.AZURE_SQL_SERVER;
const database = process.env.AZURE_SQL_DATABASE;
const port = parseInt(process.env.AZURE_SQL_PORT);
const type = process.env.AZURE_SQL_AUTHENTICATIONTYPE;
export const config = {
server,
port,
database,
authentication: {
type
},
options: {
encrypt: true
}
};
sql.connect(config); Update: And in the docs of tedious there are different authentication types. Including azure-active-directory-default. |
@MartinEide we're unopinionated by design. always refer to the underlying driver's (tedious in this case) docs for connection options. I have no idea, never used ms sql server in production. |
It appears that limit(1) isn't converted correctly, currently it adds it to the end of the select statement, however in sql server its called TOP instead of limit.
I don't think it can be used anywhere else apart from directly after the select keyword and might need to be hoisted there somehow. Maybe it would be better to add a completely different method like .top(1) but I realise that would stray from the current api. It's likely that offset will cause a similar issue as I think mysql can specify offset, limit in one line where as sql server separates them completely but I'm not that familiar with mysql. Is there another way to call limit in a query, raw sql? i'm currently using this in a nested sub query and would be happy to not have to add a method or touch the current api to get this to work if there was some other way. I've been putting this through its paces and seems to be pretty solid overall as this was the only thing I found so far, its my first time really diving into kysely but I'll keep reporting in as I explore the feasibility of bringing my c# codebase to typescript. TLDR: looks great so far |
@dylel This PR only handles the mssql dialect and introducing mssql to our existing test suites (which is a lot). Anything related to querying APIs will or will not be dealt with in other PRs if and when this PR is merged. Check the tests to see how I managed to pull things off, usually using |
@dylel Do you think it's a good idea to normalize it into |
I think the verbose solution would be better, and have them be completely separate methods. I don't like the idea of introducing 'TOP X' and would be in favor of just polyfiling .limit() to have a case for mssql so that users can just use the same api and not have to carry the mental model of "i'm using sql server therefore I have to call a different method" but i'm sure @igalklebanov has some thoughts for future PR's. I've been successfully using the modifyStart/End functions for the time being and they work well for now |
I don't think If we are going the It leaves one question, @dylel @igalklebanov wdyt? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally got to reviewing this giant! Amazing work! I have nothing to nitpick here. Let's merge this and improve as we go 💯
When will this be released? Need it soo much |
Guys? Any updates? |
* add mssql dev dependency. * add mssql to docker-compose.yml. * config? @ pg driver. * initial dialect implementation. * fix browser tests by getting tedious stuff in config. * introduce mssql to test-setup. * get dialect to a working state. * introduce mssql to insert test suite. * introduce mssql to select test suite. * add mssql to test scripts. * make tests pass type-checks. * fix new tests after update branch. * introduce mssql to update test suite. * fix mysql test expectation. * introduce mssql to delete test suite. * introduce mssql to with test suite. * introduce mssql to with schema test suite. * introduce mssql to where test suite. * test mssql vs. selectNoFrom. * introduce mssql to set operation test suite. * fix error rejections. * introduce mssql to schema module test suite. * remove mssql, add tedious and tarn. * initial pool implementation using tarn. * fix failing where tests. * fix compilation errors at select tests. * introduce mssql to schema module test suite, pt. 2. * compile mssql alter table alter column properly. * introduce mssql to schema module test suite, pt. 3. * fix failing where test. * introduce mssql to sanitize identifiers test suite. * introduce mssql to raw sql test suite. * introduce mssql to raw query test suite. * introduce mssql to order by test suite. * introduce mssql to join test suite. * introduce mssql to having test suite. * introduce mssql into group by test suite. * empty and/or works everywhere. * introduce mssql to expression test suite. * introduce mssql to execute test suite. * introduce mssql to deduplicate joins test suite. * introduce mssql to coalesce test suite. * introduce mssql to clear test suite. * introduce mssql case test suite. * introduce mssql to camel case test suite. * introduce mssql to aggregate function test suite. * lift only. * connection validate shouldn't trigger kysely stuff. * introduce mssql to transaction test suite, pt. 1. * fix introspect tests. * remove mssql types. * add @types/tedious dev dep. * introduce mssql to transaction test suite, pt. 2. * introduce mssql to introspect test suite, pt. 1. * introduce mssql to introspect test suite, pt. 2. * fix default to column introspection @ mssql. * autoincrementing columns are technically columns with default values. * dont use ifNotExists in mssql migrations. * introduce mssql to migration test suite. * implement streaming. * fix schema tests. * rename DIALECTS_WITH_MSSQL back to DIALECTS. * misc adjustments and js docs. * fix wording of `supportsCreateIfNotExists`. * add mssql to key value set variant test case.
This is now released with 0.27.0 |
Thanks for making our lives easier! 🎉🥳 |
might close #38.
This PR adds a core dialect for MS SQL Server. It uses the tedious library as the underlying driver, and the tarn library for connection pool management. All external code is provided through the dialect's config upon instantiation.
It also introduces MS SQL Server to our testing suites.
It also makes necessary small refactors in our testing suites, being more explicit about what's being tested, now that we have more than 3 core dialects.
Gaps in our querying or schema APIs relevant to mssql that should be addressed in future PRs:
output
clause so insert id can be retrieved. addOUTPUT
clause support. #828merge
queries to supporton conflict
like queries. addMERGE
query support. #700identity
method @ column builders. addIDENTITY
column support. #823bit
,uniqueidentifier
,nvarchar
data types.persisted
@ column builders.not null
) in the samealter column
clause.eb.jsonPath<$>
. #791top N
support. addTOP
clause support. #821limit offset
support. addFETCH
clause support. #822