kysely

A type-safe typescript SQL query builder

MIT License

Downloads
1.9M
Stars
9.3K
Committers
109

Bot releases are visible (Hide)

kysely - 0.21.2

Published by koskimas about 2 years ago

  • Fixes #135. Thank you @68kHeart ❤️
kysely - 0.21.1

Published by koskimas about 2 years ago

  • Fixes #132
kysely - 0.21.0

Published by koskimas about 2 years ago

  • Fix corner case bugs in withSchema
  • Make postgres cursor compatible with pg-cursor typings

Breaking changes

The internal "operation node tree" changed a little bit. This only affects you if you've implemented a custom plugin or are doing something funky with the node tree. The only change is the new node SchemableIdentifier that's used by TableNode and a small set of other nodes that can have a schema.

kysely - 0.20.1

Published by koskimas about 2 years ago

  • Fixes #131
  • Exports WithSchemaPlugin
kysely - 0.20.0

Published by koskimas about 2 years ago

  • Adds support for explaining queries. Thank you @igalklebanov
  • Adds modifyFront and modifyEnd methods to the CreateTableBuilder. Thank you @igalklebanov
  • Fixes #125. Thank you @igalklebanov
  • Fixes #129
kysely - 0.19.12

Published by koskimas about 2 years ago

Fixes a potential security issue #121. Thank you @DavesBorges ❤️

kysely - 0.19.11

Published by koskimas over 2 years ago

kysely - 0.19.10

Published by koskimas over 2 years ago

Added createType and dropType methods to the schema builder.

kysely - 0.19.9

Published by koskimas over 2 years ago

Added modifyFront and modifyEnd methods

kysely - 0.19.8

Published by koskimas over 2 years ago

Fix bug where falsy default values didn't set the hasDefaultValue value to true in ColumnMetadata.

kysely - 0.19.7

Published by koskimas over 2 years ago

Fixes #108

kysely - 0.19.6

Published by koskimas over 2 years ago

Added isAutoIncrementing and hasDefaultValue to ColumnMetadata.

kysely - 0.19.5

Published by koskimas over 2 years ago

Add support for lateral joins

const query = ctx.db
  .selectFrom('person')
  .innerJoinLateral(
    (eb) =>
      eb.selectFrom('pet')
        .select('name')
        .whereRef('pet.owner_id', '=', 'person.id')
        .as('p'),
    (join) => join.on(sql`true`)
  )
  .select(['first_name', 'p.name'])
  .orderBy('first_name')
kysely - 0.19.4

Published by koskimas over 2 years ago

Fix join method issues that caused typescript to fail with Type instantiation is excessively deep and possibly infinite.ts(2589)-

kysely - 0.19.3

Published by koskimas over 2 years ago

  • Enables tree shaking for webpack
  • Disables a webpack warning about a dynamic import in FileMigrationProvider
  • Support .mjs files in migrations
kysely - 0.19.2

Published by koskimas over 2 years ago

Fixes #93

kysely - 0.19.1

Published by koskimas over 2 years ago

The addColumn method of AlterTableBuilder now takes a third callback argument just like CreateTableBuilder.addColumn.

kysely - 0.19.0

Published by koskimas over 2 years ago

What's new

Kysely now has absolutely no internal dependecies to anything. Not even dynamic ones. The same code runs on node, deno, browser and is compatible with all bundlers out of the box! All dependencies are passed from the outside.

Breaking changes

The dialects now take an instance of the underlying db drivers's pool (or other connection object if a pool is not available). This is how you'd create an instance of Kysely in 0.19.0:

import { Pool } from 'pg'

const db = new Kysely<Database>({
  dialect: new PostgresDialect({
    pool: new Pool({
      host: 'localhost',
      database: 'kysely_test'
    })
  })
})
import { createPool } from 'mysql2'

const db = new Kysely<Database>({
  dialect: new MysqlDialect({
    pool: createPool({
      host: 'localhost',
      database: 'kysely_test'
    })
  })
})
import Database from 'better-sqlite3'

const db = new Kysely<Database>({
  dialect: new SqliteDialect({
    database: new Database('db.sqlite')
  })
})

If you want to initialize the pool lazily when it's used for the first time, you can use a thunk:

import { Pool } from 'pg'

const db = new Kysely<Database>({
  dialect: new PostgresDialect({
    pool: async () => new Pool({
      host: 'localhost',
      database: 'kysely_test'
    })
  })
})

FileMigrationProvider

I also changed the FileMigrationProvider once again, even though I promised never to do that again 😞. This was done to get rid of all dependencies. You now need to use the class like this:

import { promises as fs } from 'fs'
import path from 'path'

new FileMigrationProvider({
  fs,
  path,
  migrationFolder: 'path/to/migrations/folder',
})

Deno and browser builds

There's no more need for the index-nodeless file and it has been removed. You can simply import kysely or the index.ts file from the dist folder. Nothing refers to node or any node library.

kysely - 0.18.1

Published by koskimas over 2 years ago

  • Allow custom migration tables and schema #80
  • Allow an existing pool instance to be passed to MysqlDialect and PostgresDialect #81
kysely - 0.18.0

Published by koskimas over 2 years ago

Breaking changes

UpdateQueryBuilder now takes four type arguments instead of three. The second argument is new and is the table that will be updated. The third one is a union of all the tables that can be referred to.

This only affects you if you've been using explicit types.

What's new

  • "update set from" queries are now possible because of the from method in UpdateQueryBuilder
  • Raw aliases are now possible when using the as method of a raw sql snippet.