Skip to content

Commit

Permalink
Beta (#3543)
Browse files Browse the repository at this point in the history
* Fix breakpoints option default value

* fix: added commonly used columns to supabase auth.users table schema

* imports checker with OHM grammar

* imports checker with OHM grammar + fix of imports issues

* Formatting fix

* [MySQL] Add unsigned floating point types + Fix unsigned integer type bugs in Kit (#3284)

* Fix bugs with MySQL introspection tests

* Update float data type in MySQL

* Better support for float types in MySQL

* Handle existing unsigned numerical types in MySQL

* Add unsigned to floating point types in MySQL

* Handle unsigned floating point types in MySQL

* Update decimal data type

---------

Co-authored-by: Andrii Sherman <[email protected]>

* Batch of bugfixes for ORM (#3181)

* (MySQL) Fix placeholder type error in offset and limit

* Add prepared statement tests

* Add PG test

* Fix blob parsing in bun sqlite driver

* Lint and format

* Fix file

* Fix tests

* Use const instead of let in tests

* Format

---------

Co-authored-by: Andrii Sherman <[email protected]>

* main to beta (#3404)

* Update Github issue templates (#3157)

* Update GH issue templates

* Update issue templates

---------

Co-authored-by: Andrii Sherman <[email protected]>

* Fix checkboxes

---------

Co-authored-by: L-Mario564 <[email protected]>

* feat: add tablesFilter to pushSchema api (#3141)

* feat: add tablesFilter to pushSchema api

* Format with dprint

---------

Co-authored-by: Andrii Sherman <[email protected]>

* Batch of bugfixes for Kit (#2959)

* Escape single quote in enum value

* Escape single quotes in string default values

* Handle instrospection of strings with single quotes

* Add tests

* Add tests

* Uncomment tests

* Fix SQL statement order in MySQL

* Add MySQL test

* Fix alter composite PK statement missing quotes in PG

* Add tests

* Handle SQL expressions in timestamp, date and time in PG

* Use `.run` instead of `.query` in SQLite queries that don't return anything

* Fix parsing of enum array types in PG

* Generate more PG index operators

* Fix primary key recreate on table rename

* Format

* Format

* Update test

* Format

* Fix tests

* Fix terminal output mistake

* Remove duplicate import

---------

Co-authored-by: Andrii Sherman <[email protected]>

* Bump versions

* fix: typo (#3172)

Co-authored-by: Andrii Sherman <[email protected]>

* Fix typo (#3030)

Trivial: "You ... is ready" -> "Your ... is ready"

Co-authored-by: Andrii Sherman <[email protected]>

* [MySQL] Correct $returningId() implementation to correctly store selected fields (#2975)

* Add test to reproduce $returningId() column order issue

Currently, $returningId() only works when the primary key is in the
first column (of the Drizzle table definition not the underlying
MySQL table).

This new test checks for this behaviour by using $returningId()
when the primary key is in the second column.

See #2971

Signed-off-by: Daniel Harvey <[email protected]>

* Fix $returningId() to correctly set selected fields

The local variable `returning` computes the selected fields in
$returningId() but throws this away. Change to correctly
store config in the insert query builder.

Fixed #2971

Signed-off-by: Daniel Harvey <[email protected]>

---------

Signed-off-by: Daniel Harvey <[email protected]>
Co-authored-by: Andrii Sherman <[email protected]>

* revise and proofread project documentation (#2960)

Co-authored-by: Andrii Sherman <[email protected]>

* Fixed lack of schema name on columns in sql (#3531)

* Beta (#3503)

* Fix breakpoints option default value

* fix: added commonly used columns to supabase auth.users table schema

* imports checker with OHM grammar

* imports checker with OHM grammar + fix of imports issues

* Formatting fix

* [MySQL] Add unsigned floating point types + Fix unsigned integer type bugs in Kit (#3284)

* Fix bugs with MySQL introspection tests

* Update float data type in MySQL

* Better support for float types in MySQL

* Handle existing unsigned numerical types in MySQL

* Add unsigned to floating point types in MySQL

* Handle unsigned floating point types in MySQL

* Update decimal data type

---------

Co-authored-by: Andrii Sherman <[email protected]>

* Batch of bugfixes for ORM (#3181)

* (MySQL) Fix placeholder type error in offset and limit

* Add prepared statement tests

* Add PG test

* Fix blob parsing in bun sqlite driver

* Lint and format

* Fix file

* Fix tests

* Use const instead of let in tests

* Format

---------

Co-authored-by: Andrii Sherman <[email protected]>

* main to beta (#3404)

* Update Github issue templates (#3157)

* Update GH issue templates

* Update issue templates

---------

Co-authored-by: Andrii Sherman <[email protected]>

* Fix checkboxes

---------

Co-authored-by: L-Mario564 <[email protected]>

* feat: add tablesFilter to pushSchema api (#3141)

* feat: add tablesFilter to pushSchema api

* Format with dprint

---------

Co-authored-by: Andrii Sherman <[email protected]>

* Batch of bugfixes for Kit (#2959)

* Escape single quote in enum value

* Escape single quotes in string default values

* Handle instrospection of strings with single quotes

* Add tests

* Add tests

* Uncomment tests

* Fix SQL statement order in MySQL

* Add MySQL test

* Fix alter composite PK statement missing quotes in PG

* Add tests

* Handle SQL expressions in timestamp, date and time in PG

* Use `.run` instead of `.query` in SQLite queries that don't return anything

* Fix parsing of enum array types in PG

* Generate more PG index operators

* Fix primary key recreate on table rename

* Format

* Format

* Update test

* Format

* Fix tests

* Fix terminal output mistake

* Remove duplicate import

---------

Co-authored-by: Andrii Sherman <[email protected]>

* Bump versions

---------

Co-authored-by: Steffen <[email protected]>
Co-authored-by: Nicholas Ly <[email protected]>
Co-authored-by: Alex Blokh <[email protected]>
Co-authored-by: Sukairo-02 <[email protected]>
Co-authored-by: L-Mario564 <[email protected]>
Co-authored-by: Dan Ribbens <[email protected]>

* Dprint

* Fixed `sql` omitting schema names when processing columns, fixed related test cases

* Fixed dprint formatting issues

* Fixed lack of schema name on integration tests column references

* Removed `\!`

---------

Co-authored-by: Andrii Sherman <[email protected]>
Co-authored-by: Steffen <[email protected]>
Co-authored-by: Nicholas Ly <[email protected]>
Co-authored-by: Alex Blokh <[email protected]>
Co-authored-by: L-Mario564 <[email protected]>
Co-authored-by: Dan Ribbens <[email protected]>

* Update driver.ts (#3424)

Co-authored-by: Andrii Sherman <[email protected]>

* fix: wrong dialect set in mysql/sqlite introspect (#2865)

Co-authored-by: Andrii Sherman <[email protected]>

* Extra `update` in comment (#2864)

Removed and extra `update` text in the comment description using onDuplicateKeyUpdate

* chore: export PgIntegerBuilderInitial type as are all other pg-core columns (#2846)

Co-authored-by: Alexis Reymann <[email protected]>
Co-authored-by: Andrii Sherman <[email protected]>

* Support more types in text comparing sql expressions (#2805)

Co-authored-by: Andrii Sherman <[email protected]>

* drizzle-kit/commands/migrate: fix "you code" typo (#2801)

"put you code below" 
should be
"put your code below"

* Fixed `.generated` behaviour with non-strict `tsconfig` (fixes #2654) (#3542)

* Fix Drizzle ORM for expo-sqlite (#3197)

* Fix Drizzle ORM for expo-sqlite

closes #3195

* bump expo-sqlite version to 14.0.0 in package.json and pnpm-lock.yaml

---------

Co-authored-by: Andrii Sherman <[email protected]>

* Upgrade turbo to v2

* Wait for drizzle-orm to be ready

* Format turbo json

* Fix turbo for eslint plugin

* Add release notes

---------

Signed-off-by: Daniel Harvey <[email protected]>
Co-authored-by: Steffen <[email protected]>
Co-authored-by: Nicholas Ly <[email protected]>
Co-authored-by: Alex Blokh <[email protected]>
Co-authored-by: Sukairo-02 <[email protected]>
Co-authored-by: L-Mario564 <[email protected]>
Co-authored-by: Dan Ribbens <[email protected]>
Co-authored-by: Armand SALLE <[email protected]>
Co-authored-by: Christopher Masto <[email protected]>
Co-authored-by: Daniel Harvey <[email protected]>
Co-authored-by: wackbyte <[email protected]>
Co-authored-by: Sergey Reka <[email protected]>
Co-authored-by: Michael Lohr <[email protected]>
Co-authored-by: Mickael Lecoq <[email protected]>
Co-authored-by: Asher Chan <[email protected]>
Co-authored-by: Alexis Reymann <[email protected]>
Co-authored-by: Alexis Reymann <[email protected]>
Co-authored-by: Max Leiter <[email protected]>
Co-authored-by: Subramanya Chakravarthy <[email protected]>
  • Loading branch information
19 people authored Nov 14, 2024
1 parent 83daf2d commit 2677718
Show file tree
Hide file tree
Showing 106 changed files with 624 additions and 415 deletions.
306 changes: 144 additions & 162 deletions CONTRIBUTING.md

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@

### What's Drizzle?
Drizzle is a modern TypeScript ORM developers [wanna use in their next project](https://stateofdb.com/tools/drizzle).
It is [lightweight](https://bundlephobia.com/package/drizzle-orm) at only ~7.4kb minified+gzipped, it's tree shakeable with exactly 0 dependencies.
It is [lightweight](https://bundlephobia.com/package/drizzle-orm) at only ~7.4kb minified+gzipped, and it's tree shakeable with exactly 0 dependencies.

**Drizzle supports every PostgreSQL, MySQL and SQLite databases**, including serverless ones like [Turso](https://orm.drizzle.team/docs/get-started-sqlite#turso), [Neon](https://orm.drizzle.team/docs/get-started-postgresql#neon), [Xata](xata.io), [PlanetScale](https://orm.drizzle.team/docs/get-started-mysql#planetscale), [Cloudflare D1](https://orm.drizzle.team/docs/get-started-sqlite#cloudflare-d1), [FlyIO LiteFS](https://fly.io/docs/litefs/), [Vercel Postgres](https://orm.drizzle.team/docs/get-started-postgresql#vercel-postgres), [Supabase](https://orm.drizzle.team/docs/get-started-postgresql#supabase) and [AWS Data API](https://orm.drizzle.team/docs/get-started-postgresql#aws-data-api). No bells and whistles, no rust binaries, no serverless adapters, everything just works out of the box.
**Drizzle supports every PostgreSQL, MySQL and SQLite database**, including serverless ones like [Turso](https://orm.drizzle.team/docs/get-started-sqlite#turso), [Neon](https://orm.drizzle.team/docs/get-started-postgresql#neon), [Xata](xata.io), [PlanetScale](https://orm.drizzle.team/docs/get-started-mysql#planetscale), [Cloudflare D1](https://orm.drizzle.team/docs/get-started-sqlite#cloudflare-d1), [FlyIO LiteFS](https://fly.io/docs/litefs/), [Vercel Postgres](https://orm.drizzle.team/docs/get-started-postgresql#vercel-postgres), [Supabase](https://orm.drizzle.team/docs/get-started-postgresql#supabase) and [AWS Data API](https://orm.drizzle.team/docs/get-started-postgresql#aws-data-api). No bells and whistles, no Rust binaries, no serverless adapters, everything just works out of the box.

**Drizzle is serverless-ready by design**, it works in every major JavaScript runtime like NodeJS, Bun, Deno, Cloudflare Workers, Supabase functions, any Edge runtime and even in Browsers.
With Drizzle you can be [**fast out of the box**](https://orm.drizzle.team/benchmarks), save time and costs while never introducing any data proxies into your infrastructure.
**Drizzle is serverless-ready by design**. It works in every major JavaScript runtime like NodeJS, Bun, Deno, Cloudflare Workers, Supabase functions, any Edge runtime, and even in browsers.
With Drizzle you can be [**fast out of the box**](https://orm.drizzle.team/benchmarks) and save time and costs while never introducing any data proxies into your infrastructure.

While you can use Drizzle as a JavaScript library, it shines in the TypeScript. It lets you [**declare SQL schema**](https://orm.drizzle.team/docs/sql-schema-declaration) and build both [**relational**](https://orm.drizzle.team/docs/rqb) and [**SQL-like queries**](https://orm.drizzle.team/docs/select), while keeping the balance between type-safety and extensibility for toolmakers to build on top.
While you can use Drizzle as a JavaScript library, it shines with TypeScript. It lets you [**declare SQL schemas**](https://orm.drizzle.team/docs/sql-schema-declaration) and build both [**relational**](https://orm.drizzle.team/docs/rqb) and [**SQL-like queries**](https://orm.drizzle.team/docs/select), while keeping the balance between type-safety and extensibility for toolmakers to build on top.

### Ecosystem
While Drizzle ORM remains a thin typed layer on top of SQL, we made a set of tools for people to have best possible developer experience.

Drizzle comes with a powerful [**Drizzle Kit**](https://orm.drizzle.team/kit-docs/overview) CLI companion for you to have hasstle-free migrations. It can generate SQL migration files for you or apply schema changes directly to the database.
Drizzle comes with a powerful [**Drizzle Kit**](https://orm.drizzle.team/kit-docs/overview) CLI companion for you to have hassle-free migrations. It can generate SQL migration files for you or apply schema changes directly to the database.

And we have a [**Drizzle Studio**](https://orm.drizzle.team/drizzle-studio/overview) for you to effortlessly browse and manipulate data in your database of choice.
We also have [**Drizzle Studio**](https://orm.drizzle.team/drizzle-studio/overview) for you to effortlessly browse and manipulate data in your database of choice.

### Documentation
Check out the full documentation on [the website](https://orm.drizzle.team/docs/overview)
Check out the full documentation on [the website](https://orm.drizzle.team/docs/overview).

### Our sponsors ❤️
<p align="center">
Expand Down
4 changes: 4 additions & 0 deletions changelogs/drizzle-kit/0.28.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Bug fixes

- Fixed typos in repository: thanks @armandsalle, @masto, @wackbyte, @Asher-JH, @MaxLeiter
- [fix: wrong dialect set in mysql/sqlite introspect](https://github.com/drizzle-team/drizzle-orm/pull/2865)
15 changes: 15 additions & 0 deletions changelogs/drizzle-orm/0.36.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# New Features

- [Support more types in like, notLike, ilike and notIlike expressions](https://github.com/drizzle-team/drizzle-orm/pull/2805)


# Bug and typo fixes

- Fixed typos in repository: thanks @armandsalle, @masto, @wackbyte, @Asher-JH, @MaxLeiter

- [Fixed .generated behavior with non-strict tsconfig](https://github.com/drizzle-team/drizzle-orm/pull/3542)
- [Fix Drizzle ORM for expo-sqlite](https://github.com/drizzle-team/drizzle-orm/pull/3197)
- [Fixed lack of schema name on columns in sql](https://github.com/drizzle-team/drizzle-orm/pull/3531)
- [fix: Adjust neon http driver entity kind](https://github.com/drizzle-team/drizzle-orm/pull/3424)
- [Export PgIntegerBuilderInitial type](https://github.com/drizzle-team/drizzle-orm/pull/2846)
- [[MySQL] Correct $returningId() implementation to correctly store selected fields](https://github.com/drizzle-team/drizzle-orm/pull/2975)
3 changes: 2 additions & 1 deletion docs/custom-types.lite.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Common way of defining custom types

> **Info**: For more advanced documentation about defining custom data types in PostgreSQL and MySQL please check [custom-types.md](https://github.com/drizzle-team/drizzle-orm/blob/main/docs/custom-types.md)
> [!NOTE]
> For more advanced documentation about defining custom data types in PostgreSQL and MySQL, please check [`custom-types.md`](custom-types.md).
## Examples

Expand Down
27 changes: 7 additions & 20 deletions docs/custom-types.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# How to define custom types

Drizzle ORM has a big set of predefined column types for different SQL databases. But still there are additional types that are not supported by Drizzle ORM (yet). That could be native pg types or extension types
</br>

Here are some instructions on how to create and use your own types with Drizzle ORM

Expand All @@ -13,14 +12,11 @@ Each type creation should use 2 classes:

- `ColumnBuilder` - class, that is responsible for generating whole set of needed fields for column creation
- `Column` - class, that is representing Columns itself, that is used in query generation, migration mapping, etc.
</br>
</br>

Each module has it's own class, representing `ColumnBuilder` or `Column`:
- For `pg` -> `PgColumnBuilder` and `PgColumn`
- For `mysql` -> `MySqlColumnBuilder` and `MySqlColumn`
- For `sqlite` -> `SQLiteColumnBuilder` and `SQLiteColumn`
</br>
</br>

### Builder class explanation - (postgresql text data type example)

Expand All @@ -44,7 +40,7 @@ export class PgTextBuilder<TData extends string = string>
}
```

> **Warning**
> [!WARNING]
> `$pgColumnBuilderBrand` should be changed and be equal to class name for new data type builder
### Column class explanation - (postgresql text data type example)
Expand Down Expand Up @@ -104,11 +100,8 @@ export class PgText<TTableName extends string, TData extends string>
}
```

> **Warning**
> [!WARNING]
> `$pgColumnBrand` should be changed and be equal to class name for new data type
---

</br>
### Full text data type for PostgreSQL example

Expand Down Expand Up @@ -162,19 +155,13 @@ export function text<T extends string = string>(

## Custom data type example

---

> **Note**
> [!NOTE]
> We will check example on pg module, but current pattern applies to all dialects, that are currently supported by Drizzle ORM
</br>

### Setting up CITEXT datatype

---
> **Note**
This type is available only with extensions and used for example, just to show how you could setup any data type you want. Extension support will come soon
</br>
> [!NOTE]
> This type is available only with extensions and used for example, just to show how you could setup any data type you want. Extension support will come soon
### CITEXT data type example

Expand Down Expand Up @@ -224,4 +211,4 @@ You could add your created custom data types to Drizzle ORM, so everyone can use

Each data type should be placed in separate file in `columns` folder and PR open with tag `new-data-type:pg` | `new-data-type:sqlite` | `new-data-type:mysql`

For more Contribution information - please check [CONTRIBUTING.md](https://github.com/drizzle-team/drizzle-orm/blob/main/CONTRIBUTING.md)
For more Contribution information - please check [CONTRIBUTING.md](../CONTRIBUTING.md)
13 changes: 7 additions & 6 deletions docs/joins.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Drizzle ORM - Joins

As with other parts of Drizzle ORM, the joins syntax is a balance between the SQL-likeness and type safety.
Here's an example of how a common `1-to-many` relationship can be modelled.
Here's an example of how a common "one-to-many" relationship can be modelled.

```typescript
const users = pgTable('users', {
Expand Down Expand Up @@ -96,7 +96,7 @@ In that case, the ORM will use dark TypeScript magic (as if it wasn't already) a

This is much more convenient! Now, you can just do a single check for `row.user !== null`, and all the user fields will become available.

<hr />
---

Note that you can group any fields in a nested object however you like, but the single check optimization will only be applied to a certain nested object if all its fields belong to the same table.
So, for example, you can group the city fields, too:
Expand Down Expand Up @@ -131,15 +131,16 @@ And the result type will look like this:
}
```

<hr />
---

If you just need all the fields from all the tables you're selecting and joining, you can simply omit the argument of the `.select()` method altogether:

```typescript
const rows = await db.select().from(cities).leftJoin(users, eq(users.cityId, cities.id));
```

> **Note**: in this case, the Drizzle table/column names will be used as the keys in the result object.
> [!NOTE]
> In this case, the Drizzle table/column names will be used as the keys in the result object.
```typescript
{
Expand All @@ -156,7 +157,7 @@ const rows = await db.select().from(cities).leftJoin(users, eq(users.cityId, cit
}[]
```

<hr />
---

There are cases where you'd want to select all the fields from one table, but pick fields from others. In that case, instead of listing all the table fields, you can just pass a table:

Expand All @@ -181,7 +182,7 @@ There are cases where you'd want to select all the fields from one table, but pi
}
```

<hr />
---

But what happens if you group columns from multiple tables in the same nested object? Nothing, really - they will still be all individually nullable, just grouped under the same object (as you might expect!):

Expand Down
14 changes: 7 additions & 7 deletions drizzle-kit/README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
## Drizzle Kit

DrizzleKit - is a CLI migrator tool for DrizzleORM. It is probably one and only tool that lets you completely automatically generate SQL migrations and covers ~95% of the common cases like deletions and renames by prompting user input.
Drizzle Kit is a CLI migrator tool for Drizzle ORM. It is probably the one and only tool that lets you completely automatically generate SQL migrations and covers ~95% of the common cases like deletions and renames by prompting user input.
<https://github.com/drizzle-team/drizzle-kit-mirror> - is a mirror repository for issues.

## Documentation

Check the full documenation on [the website](https://orm.drizzle.team/kit-docs/overview)
Check the full documentation on [the website](https://orm.drizzle.team/kit-docs/overview).

### How it works

`drizzle-kit` will traverse `schema folder` or `schema file`, generate schema snapshot and compare it to the previous version, if there's one.
Based on the difference it will generate all needed SQL migrations and if there are any `automatically unresolvable` cases like `renames` it will prompt user for input.
Drizzle Kit traverses a schema module and generates a snapshot to compare with the previous version, if there is one.
Based on the difference, it will generate all needed SQL migrations. If there are any cases that can't be resolved automatically, such as renames, it will prompt the user for input.

For schema file:
For example, for this schema module:

```typescript
// ./src/db/schema.ts
// src/db/schema.ts

import { integer, pgTable, serial, text, varchar } from "drizzle-orm/pg-core";

Expand Down Expand Up @@ -63,7 +63,7 @@ CREATE INDEX IF NOT EXISTS users_full_name_index ON users (full_name);
npm install -D drizzle-kit
```

Running with CLI options
Running with CLI options:

```jsonc
// package.json
Expand Down
2 changes: 1 addition & 1 deletion drizzle-kit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "drizzle-kit",
"version": "0.28.0",
"version": "0.28.1",
"homepage": "https://orm.drizzle.team",
"keywords": [
"drizzle",
Expand Down
12 changes: 6 additions & 6 deletions drizzle-kit/src/cli/commands/introspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,14 @@ export const introspectPostgres = async (
chalk.green(
'✓',
)
}] You schema file is ready ➜ ${chalk.bold.underline.blue(schemaFile)} 🚀`,
}] Your schema file is ready ➜ ${chalk.bold.underline.blue(schemaFile)} 🚀`,
);
render(
`[${
chalk.green(
'✓',
)
}] You relations file is ready ➜ ${
}] Your relations file is ready ➜ ${
chalk.bold.underline.blue(
relationsFile,
)
Expand Down Expand Up @@ -264,14 +264,14 @@ export const introspectMysql = async (
chalk.green(
'✓',
)
}] You schema file is ready ➜ ${chalk.bold.underline.blue(schemaFile)} 🚀`,
}] Your schema file is ready ➜ ${chalk.bold.underline.blue(schemaFile)} 🚀`,
);
render(
`[${
chalk.green(
'✓',
)
}] You relations file is ready ➜ ${
}] Your relations file is ready ➜ ${
chalk.bold.underline.blue(
relationsFile,
)
Expand Down Expand Up @@ -488,14 +488,14 @@ export const introspectLibSQL = async (
chalk.green(
'✓',
)
}] You schema file is ready ➜ ${chalk.bold.underline.blue(schemaFile)} 🚀`,
}] Your schema file is ready ➜ ${chalk.bold.underline.blue(schemaFile)} 🚀`,
);
render(
`[${
chalk.green(
'✓',
)
}] You relations file is ready ➜ ${
}] Your relations file is ready ➜ ${
chalk.bold.underline.blue(
relationsFile,
)
Expand Down
2 changes: 1 addition & 1 deletion drizzle-kit/src/cli/commands/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ export const writeResult = ({

if (type === 'custom') {
console.log('Prepared empty file for your custom SQL migration!');
sql = '-- Custom SQL migration file, put you code below! --';
sql = '-- Custom SQL migration file, put your code below! --';
}

journal.entries.push({
Expand Down
6 changes: 3 additions & 3 deletions drizzle-orm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "drizzle-orm",
"version": "0.36.1",
"version": "0.36.2",
"description": "Drizzle ORM package for SQL databases",
"type": "module",
"scripts": {
Expand Down Expand Up @@ -63,7 +63,7 @@
"@xata.io/client": "*",
"better-sqlite3": ">=7",
"bun-types": "*",
"expo-sqlite": ">=13.2.0",
"expo-sqlite": ">=14.0.0",
"knex": "*",
"kysely": "*",
"mysql2": ">=2",
Expand Down Expand Up @@ -186,7 +186,7 @@
"better-sqlite3": "^8.4.0",
"bun-types": "^0.6.6",
"cpy": "^10.1.0",
"expo-sqlite": "^13.2.0",
"expo-sqlite": "^14.0.0",
"knex": "^2.4.2",
"kysely": "^0.25.0",
"mysql2": "^3.3.3",
Expand Down
12 changes: 8 additions & 4 deletions drizzle-orm/src/column-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export interface ColumnBuilderBaseConfig<TDataType extends ColumnDataType, TColu
data: unknown;
driverParam: unknown;
enumValues: string[] | undefined;
generated: GeneratedColumnConfig<unknown> | undefined;
}

export type MakeColumnConfig<
Expand All @@ -64,7 +63,10 @@ export type MakeColumnConfig<
enumValues: T['enumValues'];
baseColumn: T extends { baseBuilder: infer U extends ColumnBuilderBase } ? BuildColumn<TTableName, U, 'common'>
: never;
generated: T['generated'] extends object ? T['generated'] : undefined;
generated: T extends { generated: infer G } ? unknown extends G ? undefined
: G extends undefined ? undefined
: G
: undefined;
} & {};

export type ColumnBuilderTypeConfig<
Expand All @@ -82,7 +84,7 @@ export type ColumnBuilderTypeConfig<
notNull: T extends { notNull: infer U } ? U : boolean;
hasDefault: T extends { hasDefault: infer U } ? U : boolean;
enumValues: T['enumValues'];
generated: GeneratedColumnConfig<T['data']> | undefined;
generated: T extends { generated: infer G } ? G extends undefined ? unknown : G : unknown;
}
& TTypeConfig
>;
Expand Down Expand Up @@ -294,7 +296,9 @@ export abstract class ColumnBuilder<
abstract generatedAlwaysAs(
as: SQL | T['data'] | (() => SQL),
config?: Partial<GeneratedColumnConfig<unknown>>,
): HasGenerated<this>;
): HasGenerated<this, {
type: 'always';
}>;

/** @internal Sets the name of the column to the key within the table definition if a name was not given. */
setName(name: string) {
Expand Down
2 changes: 1 addition & 1 deletion drizzle-orm/src/expo-sqlite/driver.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SQLiteDatabase, SQLiteRunResult } from 'expo-sqlite/next';
import type { SQLiteDatabase, SQLiteRunResult } from 'expo-sqlite';
import { entityKind } from '~/entity.ts';
import { DefaultLogger } from '~/logger.ts';
import {
Expand Down
2 changes: 1 addition & 1 deletion drizzle-orm/src/expo-sqlite/query.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { addDatabaseChangeListener } from 'expo-sqlite/next';
import { addDatabaseChangeListener } from 'expo-sqlite';
import { useEffect, useState } from 'react';
import { is } from '~/entity.ts';
import { SQL } from '~/sql/sql.ts';
Expand Down
2 changes: 1 addition & 1 deletion drizzle-orm/src/expo-sqlite/session.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SQLiteDatabase, SQLiteRunResult, SQLiteStatement } from 'expo-sqlite/next';
import type { SQLiteDatabase, SQLiteRunResult, SQLiteStatement } from 'expo-sqlite';
import { entityKind } from '~/entity.ts';
import type { Logger } from '~/logger.ts';
import { NoopLogger } from '~/logger.ts';
Expand Down
2 changes: 0 additions & 2 deletions drizzle-orm/src/mysql-core/columns/bigint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export type MySqlBigInt53BuilderInitial<TName extends string> = MySqlBigInt53Bui
data: number;
driverParam: number | string;
enumValues: undefined;
generated: undefined;
}>;

export class MySqlBigInt53Builder<T extends ColumnBuilderBaseConfig<'number', 'MySqlBigInt53'>>
Expand Down Expand Up @@ -60,7 +59,6 @@ export type MySqlBigInt64BuilderInitial<TName extends string> = MySqlBigInt64Bui
data: bigint;
driverParam: string;
enumValues: undefined;
generated: undefined;
}>;

export class MySqlBigInt64Builder<T extends ColumnBuilderBaseConfig<'bigint', 'MySqlBigInt64'>>
Expand Down
Loading

0 comments on commit 2677718

Please sign in to comment.